Re: [RFC] New core autoloading mec hanism with support for function autoloading

From: Date: Tue, 11 Apr 2023 13:27:54 +0000
Subject: Re: [RFC] New core autoloading mec hanism with support for function autoloading
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-119916@lists.php.net to get a copy of this message
On 11 April 2023 13:21:08 BST, Mark Baker <mark@demon-angel.eu> wrote: >We have the special constants like \MyNamespace\MyClass::class. Would you envisage (or is there >value in) equivalent constants like \MyNamespace\MyFunction::function? This has come up before, but there are two things about ::class to bear in mind: 1) It has nothing to do with classes. It just means "resolve namespaced name", and doesn't care what string appears on its left-hand side. 2) It is calculated (except in a few specific cases) at compile-time, based entirely on the contents of the current file, with no relationship to autoloading or what is defined elsewhere. That's very different from function (and constant) lookups, which happen at run-time, and specifically check whether a function is defined in the current namespace before falling back to the global one. In other words, the value of foo::function would be dependent on runtime state in a way that Foo::class is not. Meanwhile, the main use case for such a syntax - getting a reference to use as a callback - is now well served by the first class callable syntax my_function(...) Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#119916) next »