Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125882 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 746E11A00BD for ; Thu, 31 Oct 2024 06:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1730355538; bh=DNnACdP4+8CpVS5meQMRNDhKXL04YeAAH9gXhLvyvL4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=XLdin6BRkUuoC588BAKWPlkDQ3J6am4GQZjFca1KJqsSz9SzwHTr3fSu3LIohrMz8 VCZX0zGMDHemySbeTwcSqoaTEsqx4XliUS4GrVpkVaTA/yNfGUb/9y7Poo2KBVTCWa ox+dzzkF69amPLRQpbPpqA75Vr9xUymyp56VSe8HLNdkLWn8GJoEkVMaDAKM1G3hoz F5VYIf1XDNv29b+VyL6fUSBbiqTwL1NM2vH1mGppvuWjYIdh9ryD6XjYRCPulzBeLH PVNW8xlsSX3v9RV2LuZlY91z/o3zi8XEzONrf9DKdYZQf6s6p6uNHUPpFFqTgx9y8g 2GHmsP6ObPW7w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 30B34180037 for ; Thu, 31 Oct 2024 06:18:57 +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) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 31 Oct 2024 06:18:56 +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 227D91140187 for ; Thu, 31 Oct 2024 02:16:27 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Thu, 31 Oct 2024 02:16:27 -0400 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=1730355386; x=1730441786; bh=clr1p8ZGy4CwBV9il19ZG 1bvSJkJ0tMqHfAcng/+Jac=; b=k0CDdpiFZc/+TCBn6nkFotCkdV2WvL+GzWAFN 9TTUEIB2y54DhSzFZPHbiYeuwuM1NUCEdYUAKTyf29ZOqOYGAMNsgg+vG/jAFYKy JerBkJv8mIVRsQtWEHHJjO/JvjjW1XO6sP3nUBp8l2aMPdX4QLBAAcrYKdyqqaH8 BxB3uI4uweFKLVQ+YLzo7giCzn8XpzfN+nRDR2OjikrXk2NVNweicbiXKCw6jO2E KFszkyXZ3wLFJ4wXLsBmckKsgpIt5k3qUahZAJeuKOS9xiaCWr0l17yGiHOEX69x wsfSywlNwn2hbWMkuQEE8fbP9XkQZNU1lsFKCom96hmnG8Dog== 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=1730355386; x=1730441786; bh=c lr1p8ZGy4CwBV9il19ZG1bvSJkJ0tMqHfAcng/+Jac=; b=D7lMfdidsrO3yJnnH LixVy6yYbY6pHKazHknQpxOPSMnAfchm5bOuCsnR7oAt+ul82Tki0svGvjDZswog 4nSkbj3Yx6Le46RtUX97drA1PE0qjfAyi8a5MO3xApJQ2mfemVjy9pbO4qNALXYn +szVyRafUlo3dOsFQOPGC2N+YEt7H+QQNoKqlO+HYQ6YGIkPJc8LnuZJKBwbh/KG ITS4IIIG35twkfeJcfl0IyYpe+bVbw4yrVHUm+rSSUkO5NH60UhEO0kb98kIO6TK 2e4KLZ7vIdijnt+QKvIAvIoQsiQq3YfViSl8a0AgSivtyLnTUBZo6jKOUQ9SbxmA O/7og== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdekgedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredtjeen ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdeg teeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggt hhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 9F10A29C0072; Thu, 31 Oct 2024 02:16:26 -0400 (EDT) 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: Thu, 31 Oct 2024 01:16:06 -0500 To: "php internals" Message-ID: In-Reply-To: <6f39dce9e6b0579baa51bc84cb8140b9@bastelstu.be> References: <15da4c13445d7e9c9d768c60c19768d4@bastelstu.be> <3b458165-406c-4b70-97bc-6e98d6c44c72@app.fastmail.com> <6f39dce9e6b0579baa51bc84cb8140b9@bastelstu.be> 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 Wed, Oct 30, 2024, at 3:01 AM, Tim D=C3=BCsterhus wrote: > Hi > > Am 2024-10-30 05:25, schrieb Larry Garfield: >> This seems like a good idea to me. My only real question is why we=20 >> need to forbid short-closures. I fully agree that capturing variable= s=20 >> for such functions doesn't work. What I don't understand is why that=20 >> precludes short-closures. Is it not possible to "just" say "there's=20 >> nothing to even capture in this context, don't try"? (There may be=20 >> technical reasons for that, but I do not know what they are and the R= FC=20 >> doesn't say.) > > It would indeed require some special handling to disable the=20 > auto-capturing in the code. This would be solvable of course, but=20 > there's also semantic ambiguity, because users reasonably expect short=20 > closures to perform auto-capturing: > > > $foo =3D 'foo'; > > const Closure =3D static fn (array $bar): array =3D> [$foo, $bar]; > > var_dump((Closure)('bar')); > > If this would be legal syntax: What would you expect to be printed? > > Best regards > Tim D=C3=BCsterhus Hm. It would never occur to me to use a function for a non-class consta= nt in the first place, so I don't know. :-) Frankly I can't recall the = last time I used a non-class constant period. :-) That said, PHP consts are already a bit squishy, and auto-capture is alw= ays by value. That wouldn't give us a loophole? If it cannot reasonably be done now, but is possible, that should be lis= ted in future scope with roughly what it would take for a follow-up to d= o. (And then we can argue if it should just be done now, with more info= rmation as to how much work that is.) --Larry Garfield