Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119730 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51511 invoked from network); 16 Mar 2023 22:15:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Mar 2023 22:15:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B2F8B1804AA for ; Thu, 16 Mar 2023 15:15:04 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (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, 16 Mar 2023 15:15:04 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7F573320083A for ; Thu, 16 Mar 2023 18:15:01 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Thu, 16 Mar 2023 18:15:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1679004901; x= 1679091301; bh=9JMIUtJTAnGE38jAqkR5JHdt+hm+iPNrrr4nXbzDV6A=; b=r 4kthJ6sYxVzOC73lhoH3M3gTE1o6UaokdPnLgc77AU4Od3wxMGAMf5Uyz563HyUI /0QCa7QEI2+uLHlyUZ9cW2QzFObwaM7XA/uIGtNBTPUHz1b4wAqqiBDfrrypZCMl kdoG0jPEk+7SoOCLPYRRkavZkXV3ZtEtn4+64LxrQMchCPsVmtnNyxBh1deJAMxh NI039hZ9BSEXag7St1/jfPZxKzqfmX+9Ewt3JKrh+ZzyVWrfBh4VXPW90HZRMCVR 0vDEM8Bm3DC+JvMVKM+TPg7DMGHlHAlx7jAfyRgpQs9+/2CaCjAatmny49cDR7L4 vzHZHAa2YC2m+vdTP4OvQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1679004901; x=1679091301; bh=9JMIUtJTAnGE3 8jAqkR5JHdt+hm+iPNrrr4nXbzDV6A=; b=ZfMTr+wZgGro6lZWvLRdpT9OXePfH n/RNn+3NEtX6bbkHDp+M9MHj90Pjtlj6kye8zvGkOonYTmkW+ollovXAA2hVp7RA UJpAjzz3dXJCCyfS47NifOi4d+lB+fIJrkDXgrU/IJKjuFcWY5xNnlnA18leeQ2A z232ZwZfQDaY+IkBUPy0TD9EBjWlbxgXrBb/SxSVAP60NbwhroNFEwjalF/3mHHE jb1otoVAvHWa2WapQyhGaUwwu7Cc1xFnoytkSqKoEt8uGN/6QOGgki6He9UCMUy7 xhv4+PpKW5kQ8PBRGhctcgwa1INLCY1WEU1mQFC3NAuEICd5p+ZlovqgQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeftddgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id CE2391700089; Thu, 16 Mar 2023 18:15:00 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-221-gec32977366-fm-20230306.001-gec329773 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <8a9a04b3-45e6-47dd-dee8-0f524e49bd37@gmail.com> Date: Thu, 16 Mar 2023 17:14:40 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables From: larry@garfieldtech.com ("Larry Garfield") On Thu, Mar 16, 2023, at 5:06 PM, Rowan Tommins wrote: > On 16/03/2023 17:59, Nicolas Grekas wrote: >> We could define the "use" as declaring + setting the properties before >> the constructor is called, if any. >> But I'm also fine making both constructs conflict: when there is a >> constructor, the boilerplate saved by the "use" becomes really low. >> No strong opinion either. There could be other factors to consider. > > > The main advantage of generating an actual constructor is that no change > is needed to the shared object initialization code, which could be > complex and even have performance impact. The only new logic would be in > compiling the class entry and putting the arguments into the "new > class(...)" statement. > > The more I think about it, the more I'm leaning to just blocking custom > constructors, and saying you can either have the use() short-hand, or > you can have custom initialization. Additional functionality can always > be added in later if someone comes up with a clean implementation and a > good use case. Wouldn't the functionality described boil down to essentially just materializing into a few extra lines in the constructor? At least to my ignorant non-engine brain it seems straightforward to have this: $a = 1; $b = 2; $c = 3; $o = new class ($a, $b) use ($c) { public function __construct(private int $a, private int $b) {} public function something() {} } Desugar to this: $c = class ($a, $b) use ($c) { private $c; public function __construct(private int $a, private int $b) { $this->c = 3; // By value only, so this should be fine? } public function something() {} } --Larry Garfield