Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125909 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 7E5FA1A00BD for ; Tue, 5 Nov 2024 00:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1730768385; bh=aV5zTMm8um2cWzN4tsZpoTgiCvcMnu0OWRuQHzk+9p8=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=IJLtzALte0ZtNQqkwGZAl3XEq9ENhiLeKe6QHiEfnwTqJhZFstDE61AUpptfc5mfo nbgMhZn6vkO0w0U0DuuPs9SCD57t0ZVdVw+3RbAAX1vtFjq7MgzCpSdvFQc/L4W2Wi cFkNe2ycFjwm5Jyea2hy09NWGAwdVZNdMW3qXp9kWVcw8k+UadfrgjNpSkWKIeemqY 8QmjBsd2A1MN5cY7tAlu0vB+LHZd96LRTlMi3Kq8tlBJWA6c8HCd+FCEb0NNkWcBIb kHGwFjv68IhyVa/RaO1ZA3SnPoaOzaDVFWYjL39xhvgYyu7Z6Oa29eJtqrWZSenloD iknBTn1gaz5/Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D99B2180047 for ; Tue, 5 Nov 2024 00:59:43 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) (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 ; Tue, 5 Nov 2024 00:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail2; t=1730768230; x=1731027430; bh=aV5zTMm8um2cWzN4tsZpoTgiCvcMnu0OWRuQHzk+9p8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=SuXuLnQmauexkaqLIYuWqEb4NBXeKKqWT3YtW1uyppVb11oGL1gLks93Ad2qanMr4 mFuC3saSjrAMOKm8nN6MJHmnSWRgEtUKEj9pFAMkqDwOjIQY6k/0O6qiDhT8VGJwqt 9r/zkiuVGoLWkxrG7l6xNCNpNctOxkGUaFvIrcsfO8mTkQ7QuFmn8ixPhxpAxZpNSt ej/FtabLbfs6klAiJ+sEyFfu3WBJwV1KiuKQ/ZpViD9HvvpCrJOakDNvNiXGLkoC5C mm8zNPMURVjCpCvsHy1qdhBvJimsLscPw1/QctMU0ptcziDAunt6QIh+wlP1ShougD 0r2btoazHSiRA== Date: Tue, 05 Nov 2024 00:57:04 +0000 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] RFC: Support Closures in constant expressions Message-ID: <2sPXJojAve1IIS8SoHTv2VumjKcVe0iTwygretTEfvf8KVMw_qPZf3vKUfC1GrOk979EvXmKm86igz06Dk6VpOkkMMeU5vYvB4qghjyuk6g=@gpb.moe> In-Reply-To: <6bffc58a-b869-495e-9be8-0590822e6d79@app.fastmail.com> 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> Feedback-ID: 96993444:user:proton X-Pm-Message-ID: 1273631e54ffc27dff4ba49933b3a0b92625e186 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") On Monday, 4 November 2024 at 20:32, Larry Garfield 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 dis= allow it. Which roughly translates to detecting if a closure tries to use a= n unbound variable statically. Which is probably more difficult than 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. You know very well that PHP has tricky semantics that make figuring out "is= this case ok but not this" near impossible. Moreover, having short closure work in *some* but not *all* cases is also j= ust hella confusing, banning it for all is clear and easy to reason about. >=20 > > > 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 follow-u= p > > > to do. (And then we can argue if it should just be done now, with mor= e > > > information as to how much work that is.) > >=20 > > I have added an entry to the =E2=80=9CFuture Scope=E2=80=9D section. Se= e also my reply > > to Alex. > Thanks. Can you include what the implementation challenges are for the fu= ture-scope items, to explain why they're being punted to later rather than = addressed now? (As there seems clear interest in having all of them.) >=20 I have never seen a future scope section which describes these challenges, = and this feels just giving more work to people for no benefit? There has been clear intent on having Pattern matching and ADTs, yet they w= ere split out because they are different scopes. It is *fine* to have smaller incremental RFCs that build on top of each oth= er without needing to provide justification as to why it was punted to late= r. Arguably, the onus should be on people wanting it to be in the RFC to do th= e research and provide some implementation idea to have them be one RFC for= this discussion to be at all reasonable. Best regards, Gina P. Banyard