Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126076 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 5D09E1A00BD for ; Wed, 27 Nov 2024 22:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732744934; bh=2sa1KhBSqNZXl7p2iRDojTYHSglpBDW0hhKf798DsZA=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=M5yFfwj105Fo3PDg2rPcgbssetCDLKHvTjGMaUeKtptvOzGZluJKRsXpzUVknva4R VA0PyekpX+1/f+/KxqlMjcUUsXFpsxfMywy6a1Ul+GKT4tNN+D5doCYpv/72pZG9ne n+FDWxUwOl3hdGQBtVT0kq2qAFnAhK8a8UHcZOfZtjI7pFjcY1LsmBbeDRsu7DFRUU ILW6VVCPKlVXR/1kqZaAvz8L+xRkge8bZz+p+3x5M96ZkDPt8dgGCi7J08g6W/nLVk EV1i7gIa92n9Z5EmHeOERzM3/M7GPHWKVX6Dcub1+CnRJJEJHZmuBjMDNHr52r3gVe nwBnm9viIUhVw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1E124180069 for ; Wed, 27 Nov 2024 22:02:14 +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=2.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from cow.ash.relay.mailchannels.net (cow.ash.relay.mailchannels.net [23.83.222.41]) (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 ; Wed, 27 Nov 2024 22:02:13 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E75D623422 for ; Wed, 27 Nov 2024 22:05:21 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (trex-8.trex.outbound.svc.cluster.local [100.122.110.163]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 0A35121CE8 for ; Wed, 27 Nov 2024 22:05:20 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1732745121; a=rsa-sha256; cv=none; b=1rAm9BFrMFdrbF1A5o50IrkoYtSAwbkR2+OncjxezA7K4PxsY5IQu3xHYC0gWG+XPFKdok 2F1uXrua9vrAsH1CPi58Eq0CSjFRhqXsNICILeX5Xt5XSULFBJtt/V5PJZuA9OkuKI5Or0 EupQlAo8FzlA2k9D/4wUBzZo68MZw5fm9fmU1h579l5iSavChyI+t9U/zMvTYN7Osh2UIk MEAm0rZtfNphSK8KWvsxZCW3ZSYNKwMsgtbMPUHABuZQ5oqm+t1ZzOJboAlo79WoEy5Fpw ArmqhFA1u0qzVW7asAuPt0PQjcAupzhyVEBhVvwt1yjF7IeVcMaAnX3sSvQS4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1732745121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dtNYSao+di9SGxkucZzCl9S2HqRYzTS+sgY+cVzFONk=; b=duQ+k70JBAT1Vxy53qRwWDiPIRM9SVoyGlJioeDMw1cn/0x4lFByjYzPM2/bNhts2B+rif 7Uji7nCVjgV3NjDAsshfSvf5iFIuOyL0ud0iWS7a/htmQrLeDioSvsgutN7DpC0NL33k+2 /Ym4xJWbf7E7jn6PwW4t91r+RFsbchz/TwvJ3Vue7CYdURRu6kJr6TXnRr+E3OmIHz1J8w 5m2cBSc3qE9Vp3VvofNqy3g9Cx0D3VifbBAE/ODmzP13ixXMAp8OFvUIb6lU9UcJhPTpa7 +0Zrx3oOp6BIfC6iizabIhcxP3fQ6gJTxIGAUOpyXGKGX+r3zYmi6zxmTz3Rgw== ARC-Authentication-Results: i=1; rspamd-868968d99d-vhwkx; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Slimy-Bored: 6b21b99246a55759_1732745121555_521206807 X-MC-Loop-Signature: 1732745121555:2141759700 X-MC-Ingress-Time: 1732745121555 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.122.110.163 (trex/7.0.2); Wed, 27 Nov 2024 22:05:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:Cc:References:To:Subject:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dtNYSao+di9SGxkucZzCl9S2HqRYzTS+sgY+cVzFONk=; b=Omry2kw3aqLm0pr4uw0XbWZndW X2Hzz7Mo15mXZkM6QPyaj/SZZaspatLFh6dPPNre3ZbzB6p2BWgcjfyEQSNvcETrVyQiP8zJl0RJg jFBK1UQvHUoZbpFIWeu2HLpA/VdXXXyf+McqFp1rBcm23GPfi58PpC5CSA0rNVzbU0Xo=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.98) (envelope-from ) id 1tGQ9v-0000000BCaX-12do for internals@lists.php.net; Wed, 27 Nov 2024 23:05:19 +0100 X-ImunifyEmail-Filter-Info: UkNWRF9WSUFfU01UUF9BVVRIIElFX1ZMX0JVUlNUX0FDQ09V TlRfMDJ EIFJDVkRfVExTX0FMTCBJRV9WTF9CVVJTVF9BQ0NPVU5UXzAwRCBWRV JJTE9DS19DQiBNSURfUkhTX01BVENIX0ZST00gQkFZRVNfSEFNIEZST 01fRVFfRU5WRlJPTSBUT19NQVRDSF9FTlZSQ1BUX1NPTUUgUkNQVF9D T1VOVF9USFJFRSBUT19ETl9TT01FIEZST01fSEFTX0ROIE1JTUVfVFJ BQ0UgUkNWRF9DT1VOVF9PTkUgSUVfVkxfUEJMX0FDQ09VTlRfMDEgQV NOIEFSQ19OQSBNSU1FX1VOS05PV04= X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Score: 1.13 X-ImunifyEmail-Filter-Version: 3.8.7/202411271014 Received: from [31.201.40.213] (port=58873 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98) (envelope-from ) id 1tGQ9v-0000000BCZs-33oF; Wed, 27 Nov 2024 23:05:19 +0100 Subject: Re: [PHP-DEV] [VOTE] Support Closures in constant expressions To: =?UTF-8?Q?Tim_D=c3=bcsterhus?= , internals@lists.php.net References: <6a1940027c8c534e62bfb13d222947bf@bastelstu.be> <67479414.8070302@adviesenzo.nl> <8e0d5c13-07ae-4357-88c2-f7f9bb54f614@bastelstu.be> Cc: volker@tideways-gmbh.com Message-ID: <6747979E.5090401@adviesenzo.nl> Date: Wed, 27 Nov 2024 23:05:18 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: <8e0d5c13-07ae-4357-88c2-f7f9bb54f614@bastelstu.be> Content-Type: multipart/alternative; boundary="------------010302000809010703040105" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------010302000809010703040105 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 27-11-2024 22:58, Tim Düsterhus wrote: > Hi > > On 11/27/24 22:50, Juliette Reinders Folmer wrote: >> One thing I'm wondering about - and of which I saw no mention in the RFC >> nor in the preceding discussion - knowing that function names are >> case-insensitive, how is ambiguity handled when _calling_ a callback >> stored in a (class) constant ? > > Nothing changed about the grammar or the way a PHP program is parsed > into Opcodes. As mentioned in the RFC it does not include any > backwards incompatible changes, except for making some illegal PHP > programs legal. > > In fact you are already able to store Closures in dynamic constants > defined with the `define()` function (https://3v4l.org/u7ZJ1). > > In any case that means that all your examples are interpreted as > function calls. You need parentheses around the constant name to > "dereference" the value stored in the constant. This is consistent > with $obj->foo() always being a method call to the foo() method, not a > call to a Closure stored in a property called $foo. > > Best regards > Tim Düsterhus > Thanks for the clarification. Might be good to mention this in the documentation eventually. --------------010302000809010703040105 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 27-11-2024 22:58, Tim Düsterhus wrote:
Hi

On 11/27/24 22:50, Juliette Reinders Folmer wrote:
One thing I'm wondering about - and of which I saw no mention in the RFC
nor in the preceding discussion - knowing that function names are
case-insensitive, how is ambiguity handled when _calling_ a callback
stored in a (class) constant ?

Nothing changed about the grammar or the way a PHP program is parsed into Opcodes. As mentioned in the RFC it does not include any backwards incompatible changes, except for making some illegal PHP programs legal.

In fact you are already able to store Closures in dynamic constants defined with the `define()` function (https://3v4l.org/u7ZJ1).

In any case that means that all your examples are interpreted as function calls. You need parentheses around the constant name to "dereference" the value stored in the constant. This is consistent with $obj->foo() always being a method call to the foo() method, not a call to a Closure stored in a property called $foo.

Best regards
Tim Düsterhus


Thanks for the clarification. Might be good to mention this in the documentation eventually.
--------------010302000809010703040105--