Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125913 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 9ED201A00BD for ; Tue, 5 Nov 2024 17:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1730829154; bh=bGPxHvV4mxhVAj/8BxVrXnm4KJ+PpZPwVZRD89R1nok=; h=Date:From:To:In-Reply-To:References:Subject:From; b=A8M6JaYSq5le9xTQa2IgbpL+HMbBT1Rz/GQZIN+C1clUZrYU71TeRuNdoJ2Qk8Rdt NF9RHJF2xcSgKdkzsZE0oRKuCor7eUQcrQ+Px4vy6kdblhWu2LbyS9zXDiTBLQLrjl TWLjqOamHcxOlub2f1GPVc1wu2rn9uPfRpJ5vXCjp5rlI7tEXcXTYAsF6u7eZI08/b 8LJMRS9aJPF8BMTtTbSw6rigSvrAjcIMBWnmgpcFbIzYJ0tcWlUh7i+0NMuq/EK5e1 4qO8NyA5UL4h5joQZjEEzJ4cyPmgjmPG5omSmlcWERv4RA9TWKZkwz1IlUKpWg2yVn l5IaZ2Y+t3pMA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8D49F180068 for ; Tue, 5 Nov 2024 17:52:33 +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,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b8-smtp.messagingengine.com (fout-b8-smtp.messagingengine.com [202.12.124.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 5 Nov 2024 17:52:32 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 1071A114014D for ; Tue, 5 Nov 2024 12:50:01 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Tue, 05 Nov 2024 12:50:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm3; t=1730829000; x=1730915400; bh=uB1wCyzxSgtNIiQLEpj2z RyffDNSxZD0TGYBtbvio6I=; b=FyQw4+F2IexHsHihvEPNcC//tIlxECfS7c55F hQtmR60LunXphxLWWaaCp7lRP7nzfVV4gj1S1qA6wX+U8a4P8DwGFy69Inq/0dbb 8v3qPW4AMN4Ug/Q9Fv5L475C8DQeEYsDg5pPo3n0iE+pD7w+fmnK7XiOgUC2Hwcb RNUFpcClB1t3/GhpwUXiCTM3C/ogli6k518U1xtKt8WohuSvW7r+RMWds2V4xuRP 2jqGWsGnJm93j2VI5KdBkLxWtAI+wkoK3KZpC/aRi82tMM07SReaexqwISGa02Vy 2Kr5MQAZFU5yXsuOYi/lWidf6TkeGwqTaMefuPtI/lTZTafiQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1730829000; x=1730915400; bh=u B1wCyzxSgtNIiQLEpj2zRyffDNSxZD0TGYBtbvio6I=; b=NWy+UmqEKxqLfq7nt x7bP1Y1M/ulDR1Nf86IIKiNM80Gb5+bkujgVOQ1mRReEhheDRTR2eUZAUzj8fDnb Gd8cJpN+CfpWqABD/LbdfS6ditiuTIQ9D/mtROHZmeFHFtpDh/hwbQYXovoh3n9x PHC1moyss8rHjRmfLl8DSahVv3YJK0vaJZzAbWjFs9ruFliMOE0DEQjLgI8tO7gu rRIaRdWXxtUhHnrOFcX6JexWVDKG5apHEz0PryqgtXxgZJ2oYZBsc6/ElYBVRTw/ yxtYn3vj5SlezetmoeRVVU4qHe29hpyEBNiK3lmJduhVnJl7lMHgCyKb0pRWkAue uLfkw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrtddtgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecu hfhrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivg hlughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepffeiiedvhfdvgedutddtgeet ieeugeevhfetheeffeefteduiedthedtgeejueeinecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghh rdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtth hopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id A264829C006F; Tue, 5 Nov 2024 12:50:00 -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: Tue, 05 Nov 2024 11:49:40 -0600 To: "php internals" Message-ID: In-Reply-To: <2sPXJojAve1IIS8SoHTv2VumjKcVe0iTwygretTEfvf8KVMw_qPZf3vKUfC1GrOk979EvXmKm86igz06Dk6VpOkkMMeU5vYvB4qghjyuk6g=@gpb.moe> References: <15da4c13445d7e9c9d768c60c19768d4@bastelstu.be> <3b458165-406c-4b70-97bc-6e98d6c44c72@app.fastmail.com> <6f39dce9e6b0579baa51bc84cb8140b9@bastelstu.be> <219e4bbc0b94c35d2410fb640db6c477@bastelstu.be> <6bffc58a-b869-495e-9be8-0590822e6d79@app.fastmail.com> <2sPXJojAve1IIS8SoHTv2VumjKcVe0iTwygretTEfvf8KVMw_qPZf3vKUfC1GrOk979EvXmKm86igz06Dk6VpOkkMMeU5vYvB4qghjyuk6g=@gpb.moe> Subject: Re: [PHP-DEV] RFC: Support Closures in constant expressions Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Mon, Nov 4, 2024, at 6:57 PM, Gina P. Banyard wrote: > On Monday, 4 November 2024 at 20:32, Larry Garfield=20 > wrote: > >> On Mon, Nov 4, 2024, at 6:06 AM, Tim D=C3=BCsterhus wrote: >> >=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? >>=20 >>=20 >> My expectation is that it's confusing, and therefore we should simply= disallow it. Which roughly translates to detecting if a closure tries t= o use an unbound variable statically. Which is probably more difficult t= han I make it sound. :-) > > Which is why short closures are being disallowed. > The value of it *is* limited, and the semantics of it are confusing. > I am struggling to see why this is such a big deal. I suspect, since several people have asked about it, it's because most o= f the use cases for having a default Closure value are going to be short= ; the sort of short cases that short-closures and FCC are designed for. = If it's long, then you're probably better off moving it to a private me= thod and making a FCC reference to that private method the default value= instead. So if most of the use cases align with where one would use short-closure= s and FCC, not being able to is disappointing, even if the reasons for i= t are valid. >> > > If it cannot reasonably be done now, but is possible, that should= be >> > > listed in future scope with roughly what it would take for a foll= ow-up >> > > to do. (And then we can argue if it should just be done now, with= more >> > > information as to how much work that is.) >> >=20 >> > I have added an entry to the =E2=80=9CFuture Scope=E2=80=9D section= . See also my reply >> > to Alex. > >> Thanks. Can you include what the implementation challenges are for th= e future-scope items, to explain why they're being punted to later rathe= r than addressed now? (As there seems clear interest in having all of th= em.) >>=20 > > I have never seen a future scope section which describes these=20 > challenges, and this feels just giving more work to people for no=20 > benefit? I'm not asking for a detailed description of the engine nuances of detec= ting unbound variables. Just something along the lines of "this would r= equire detecting unbound variables, that's hard, so we'll save that for = later." Which is a level of detail I frequently do provide in my RFC fu= ture-scopes. --Larry Garfield