Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120036 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84230 invoked from network); 14 Apr 2023 04:35:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Apr 2023 04:35:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9E9EC1804DF for ; Thu, 13 Apr 2023 21:35:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 13 Apr 2023 21:35:51 -0700 (PDT) Received: by mail-yb1-f173.google.com with SMTP id g10so824979ybu.8 for ; Thu, 13 Apr 2023 21:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681446950; x=1684038950; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=W+3xkbkYhUJv+cqzffBEKSJKBAC0g7NrknwsY1W3IEE=; b=CyYZ9/p2lkNUIvpbRB+La2nfzajzYTUQ0032tH66E90oTOgPdxaGVmtSAf7jyTbCph L/1/i13vnnge+8uhEdqWm8gQcQrwgzXKEzmilJQeaYCde5L6zsjRiKeq8zBf+w1NWWdk Q1Vgt+OGd9GpJDMzCK9/CTXo6q+aJ6NW4YXPgKLJCCDroiE4oxGGLUyUh8LYtMsmnHev Ba+gKv+6Apket1uXI07R3oHs2UaWeyx4FTz/UbQ6RL+kwWQj469nUVFcKTraq05Bg+TG TPyxY7uI2lWZYvwuib4APsZxQfgN1nPtui4gm1HZeZp1U2crPXRdIS1L5eVfQVuPPbfE EG1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681446950; x=1684038950; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W+3xkbkYhUJv+cqzffBEKSJKBAC0g7NrknwsY1W3IEE=; b=hsBmcgy3+SyeW3s3WiZNJQ4Ho4dpLQV+p8nAmZZo6Q8Xbc3yZYpa+XXoN9MKDwznJe TD7dcIkBFrcCabOmlGF6hItHTqamYiAg9Mo95kw150iMvjv24nMeIEJ9jnT60gL2njZj XbxcEvf4aW6qOmbUUBLZAoahyd8AkRPsDVVv/gA9zfcE0ND+wbjVsbB9dxBhsT8Jz1EF GNU5n0wJYph1smZQOFaRiyLeqllBc63cWcIFydi1sYEHe6re774hh/9BWFPxST81p8ue S/jzd4AjT8lKxB2R8/hoMJywueCgTN8UQ8qALBfuCoFGOjOnhp2Q4xt6X5iGJUHnZRtd 9h9w== X-Gm-Message-State: AAQBX9digQ8BViFs1D7XKfsZb/xIp1+2DEy62oRVTBxiyf8l/OCXImvc 6D8pFY2pFg/5bAc/8PNmjxHnLYAfctn/tFXySRo= X-Google-Smtp-Source: AKy350aCXK1eGq6TKwbA1Hdgop23K32y3yOQIadXKSbtOy65MauMbyPHWoIU+pZp3P+cN03Bo4taB5JZk2MHMXHdlwI= X-Received: by 2002:a25:cf4e:0:b0:b8f:5519:74b with SMTP id f75-20020a25cf4e000000b00b8f5519074bmr2651987ybg.0.1681446950498; Thu, 13 Apr 2023 21:35:50 -0700 (PDT) MIME-Version: 1.0 References: <8a9a04b3-45e6-47dd-dee8-0f524e49bd37@gmail.com> <52a5a80d-f03f-5e96-4188-272a705e3fdd@gmail.com> In-Reply-To: Date: Fri, 14 Apr 2023 06:35:39 +0200 Message-ID: To: Nicolas Grekas Cc: php internals Content-Type: multipart/alternative; boundary="0000000000003176cb05f9446048" Subject: Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --0000000000003176cb05f9446048 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nicolas, czw., 13 kwi 2023 o 14:40 Nicolas Grekas napisa=C5=82(a): > Hi Rowan, hi all! > > Le ven. 17 mars 2023 =C3=A0 15:51, Larry Garfield a > =C3=A9crit : > > > On Thu, Mar 16, 2023, at 6:05 PM, Rowan Tommins wrote: > > > On 16/03/2023 22:14, Larry Garfield wrote: > > >> Wouldn't the functionality described boil down to essentially just > > materializing into a few extra lines in the constructor? At least to m= y > > ignorant non-engine brain it seems straightforward to have this: > > >> > > >> $a =3D 1; > > >> $b =3D 2; > > >> $c =3D 3; > > >> > > >> $o =3D new class ($a, $b) use ($c) { > > >> public function __construct(private int $a, private int $b) {} > > >> public function something() {} > > >> } > > >> > > >> Desugar to this: > > >> > > >> $c =3D class ($a, $b) use ($c) { > > >> private $c; > > >> public function __construct(private int $a, private int $b) { > > >> $this->c =3D 3; // By value only, so this should be fine? > > >> } > > >> public function something() {} > > >> } > Have you thought about not populating property by default but instead: * adding "use" language construct as default to all methods? * adding ability to assign variable values from "use" to property if needed= ? Like desugar to $c =3D class ($a, $b) use ($c) { private $c =3D $c; // optional, not required, no conflicts public function __construct(private int $a, private int $b) use ($c) { $this->c =3D $c % 2 ? 3 : 5; } public function something() use ($c) { return $c; } } Or there is something so wrong with this thinking I cannot see yet. Cheers, Micha=C5=82 Marcin Brzuchalski --0000000000003176cb05f9446048--