Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100901 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6718 invoked from network); 15 Oct 2017 19:10:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2017 19:10:48 -0000 X-Host-Fingerprint: 95.144.122.1 unknown Received: from [95.144.122.1] ([95.144.122.1:2054] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/06-11059-6B2B3E95 for ; Sun, 15 Oct 2017 15:10:47 -0400 Message-ID: <51.06.11059.6B2B3E95@pb1.pair.com> To: internals@lists.php.net References: Date: Sun, 15 Oct 2017 20:10:42 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 95.144.122.1 Subject: Re: [PHP-DEV] Re: Suggestion Method Constant From: ajf@ajf.me (Andrea Faulds) Hi Niklas, Niklas Keller wrote: >> >> Hi Mathias, >> >> >> Mathias Grimm wrote: >> >>> I would like to suggest a method constant that could be used the same way >>> we use the ::class one >>> >>> I don't have a strong personal preference but it could be something like: >>> >>> MyController::myActionMethod::method, no sure about the internals but it >>> would be consistent with the one for the class. >>> >>> Cheers, >>> >>> >> I've long wanted to make constant lookups fall back to a closure of the >> correspondingly-named function, where one exists. so `strlen` would resolve >> to a closure of strlen(). >> >> Thing is that classes are weird. We sort of have three different things >> with sometimes-similar syntax: constants, methods and properties. foo::bar >> is a constant, foo::bar() is a function, $foo->bar() is a function, but >> $foo->bar is not a constant. So, if I want $foo->bar to resolve to a >> method, then $foo::$bar should too, even though that makes no sense. The >> PHP static property syntax is the bane of my existence. > > > Please no fallbacks, thanks. It was already a mistake for namespaced > functions. I'm not exactly a huge fan of fallbacks myself. If we were to have such a fallback, I'd like to deprecate overlapping method/property/constant names and throw warnings to that effect, with an obvious goal of eventually merging those namespaces. …hey, if we merged properties and constants together, you could do Foo::bar = $baz; instead of having to use the annoyingly inconsistent Foo::$bar syntax. I'd love that. -- Andrea Faulds https://ajf.me/