Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125904 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 9F1351A00BD for ; Mon, 4 Nov 2024 12:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1730723786; bh=dLHCuXx6i+IIw4fPro/7oL2y/4BtV1niRea0mUuSYGw=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=RCJPC8ylO9ykKq+9eePBKUMZQuvCR+gCrSe43+y08MEFDQC94ycfh2PRUw5luM/eu MqUuC/BgvgI115vxdFYo8xhaBdmQ2IiQAcx/GwL09ER1UwB0OGaKRfkid6RiDF+guW LOTnwibvYxKqSVWoyfdr0dcGrJX6dJ6J8m/GAzXY8fop1HL/PzZwZD7QO3IkPkTTvz BKFpj219+Dbv6w2okg3kCtPtGA3sy0bsmraYjG+OoTOGXmzPA0NYUwrubWVBg/oO6b 9a48eYHZbZilAambhpC1u7v8A0oLdDwvn7ixCPp5A/fxLDiRUK8lx2yNbgAUYas6wn mJKXBB6IDl4RQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AF2C6180004 for ; Mon, 4 Nov 2024 12:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 4 Nov 2024 12:36:25 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 99C101380158; Mon, 4 Nov 2024 07:33:53 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Mon, 04 Nov 2024 07:33:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1730723633; x= 1730810033; bh=Ljpxb0M95hGMbrsuj15EM7/4UNwkJRNaR9YXnZ2E3WY=; b=a lWo34fgP9Mbio1BTVPFmrlI7sH9NZApsBpmNhgkOFOVkSbtaaWiIGNU1ObAZOgkj gKSHkL3cVzFzEcxagf5WD93WY/wdmTudj781VFGYiz4hRjDKb4GBmlJ91tQ5Fzbm Qx0k1ITh+5YbcSIe3ZSAtY4AoP49/Si5upZUC76XWu/4P8B5Evc72MqgT8bsGA4v 5hLsCnb5rFV8sWnCJv0fmx4qwcLyJNWQWFIR9qYGoisezwL8+Io+nvQAWiIjOVr3 bJH4TFrfzJ4c3JNYWAELB8NIW/PMtqJM5ibIz4GApCsTM5+MbR59Rj/i8VP/815F 9UmGPpkXgv43oAa9M56pw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1730723633; x=1730810033; bh=Ljpxb0M95hGMbrsuj15EM7/4UNwkJRNaR9Y XnZ2E3WY=; b=Ulfa3F+LOtyxPyc+SMYrdIHiC+BTzhNQ11Um4ng6NiZXklaq9+H Vw9ZrFtsl0AQNVTBatM5yVjCyFb5jXVdditXg0HRVuocOVqV/MqNemqxIZW/DOag NmFkLzlyWmi+BzCp6IS0IQWOK1pdhFPF0lI7rFVb4WzGUgP0EW/CcVYX8C6okF1L d9EFOAUTPSmhZaOULY6eEfJAlMQZ5SeenRjrh+X1mW5dJ58yrzDWMzHXsFXyRHZ5 DFTWPNySWsqN4ixq0ZkE7KXkcy1j16F5doKO/m9uxi3WXG2ic+Os0EDiv3Hw+lFW oz5T7evtFbUue55vRnDPzsph5G5LkZiLTLw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdeliedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeen ucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtoh guvghsqeenucggtffrrghtthgvrhhnpeeiueethedvvdefjefhgfeiheelheehtdfhfeek jefflefgvedvkeduteejjedttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphht thhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehtihhmsegsrghsthgvlh hsthhurdgsvgdprhgtphhtthhopehlrghrrhihsehgrghrfhhivghlughtvggthhdrtgho mhdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 1FCAA780068; Mon, 4 Nov 2024 07:33:53 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Mon, 04 Nov 2024 13:33:32 +0100 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , "Larry Garfield" Cc: "php internals" Message-ID: In-Reply-To: <219e4bbc0b94c35d2410fb640db6c477@bastelstu.be> References: <15da4c13445d7e9c9d768c60c19768d4@bastelstu.be> <3b458165-406c-4b70-97bc-6e98d6c44c72@app.fastmail.com> <6f39dce9e6b0579baa51bc84cb8140b9@bastelstu.be> <219e4bbc0b94c35d2410fb640db6c477@bastelstu.be> Subject: Re: [PHP-DEV] RFC: Support Closures in constant expressions Content-Type: multipart/alternative; boundary=ef064103e48542a9bc95265ec8b51f86 From: rob@bottled.codes ("Rob Landers") --ef064103e48542a9bc95265ec8b51f86 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Nov 4, 2024, at 13:06, Tim D=C3=BCsterhus wrote: > Hi >=20 > Am 2024-10-31 07:16, schrieb Larry Garfield: > > Hm. It would never occur to me to use a function for a non-class=20 > > constant in the first place, so I don't know. :-) Frankly I can't=20 > > recall the last time I used a non-class constant period. :-) > >=20 > > That said, PHP consts are already a bit squishy, and auto-capture is=20 > > always by value. That wouldn't give us a loophole? >=20 > Here's another brainteaser: >=20 > function foo( > string $bar, > Closure $baz =3D static fn () =3D> $bar, > ) { > var_dump($baz()); > } >=20 > foo('captured'); >=20 > What would you expect the semantics of that script to be? Isn't this semantically equivalent to: function foo( string $bar, Closure $baz, ) { $baz =3D static fn () =3D> $bar; var_dump($baz()); } foo('captured'); =E2=80=94 Rob --ef064103e48542a9bc95265ec8b51f86 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Mon, Nov 4, 2024, at 13:06, Tim D=C3=BCsterhus wrote:<= br>
Hi

Am 2024-10-31 07:16, schrieb Larry Garfield:
> Hm.  It would never occur to me to use a function for = a non-class 
> constant in the first place, so I d= on't know. :-)  Frankly I can't 
> recall the= last time I used a non-class constant period. :-)
>&nb= sp;
> That said, PHP consts are already a bit squishy, = and auto-capture is 
> always by value.  That= wouldn't give us a loophole?

Here's anothe= r brainteaser:

     fun= ction foo(
        = ; string $bar,
       &= nbsp; Closure $baz =3D static fn () =3D> $bar,
 &n= bsp;   ) {
      &= nbsp;  var_dump($baz());
     }

     foo('captured');

What would you expect the semantics of that s= cript to be?

Isn't this semant= ically equivalent to:

   &nb= sp; function foo(
      &nbs= p;  string $bar,
      =    Closure $baz,
     ) {
         $baz =3D static fn () =3D&= gt; $bar;
         var= _dump($baz());
     }
     foo('captured');
=E2=80=94 Rob
--ef064103e48542a9bc95265ec8b51f86--