Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-05-05 Thread Derick Rethans
On Mon, 10 Apr 2023, G. P. B. wrote: > Hello Internals, > > Dan and I would like to propose a new core autoloading mechanism that fixes > some minor design issues with the current class autoloading mechanism and > introduce a brand-new function autoloading mechanism: >

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-17 Thread Robert Landers
Hello, This looks really interesting but it might be a good idea to add a section for the definition of "pinning" and the scope of the pin. For example, what is the output of this code, executed in this order (with this new autoloading configured): // Test.php namespace Test { function

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-16 Thread Dan Ackroyd
On Thu, 13 Apr 2023 at 11:39, Jordi Boggiano wrote: > > On 2023-04-12 22:26, Rowan Tommins wrote: > > I could just about live with that example changing so that the > > fallback was cached, but I definitely don't think an explicit call > > like \foo\strlen('x') should become an implicit alias for

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-16 Thread Dan Ackroyd
On Mon, 10 Apr 2023 at 14:01, Ondřej Mirtes wrote: > > I don’t like the proposed function names: I think we're going to leave thinking about changing the names until the end of the discussion. They don't really matter, and it probably would be better to avoid clogging up the technical

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-13 Thread Jordi Boggiano
On 2023-04-12 22:26, Rowan Tommins wrote: I could just about live with that example changing so that the fallback was cached, but I definitely don't think an explicit call like \foo\strlen('x') should become an implicit alias for \strlen('x'), which is apparently the current proposal. I

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-13 Thread Rowan Tommins
On 12 April 2023 23:50:25 BST, Dan Ackroyd wrote: >On Wed, 12 Apr 2023 at 17:32, Claude Pache wrote: >> >> The proposed modification of `function_exists()` will break existing code: > >Please can you submit a failing test to >https://github.com/Girgias/php-src/tree/zend_autoloader that shows a

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-13 Thread Rowan Tommins
On 12 April 2023 23:50:25 BST, Dan Ackroyd wrote: >On Wed, 12 Apr 2023 at 17:32, Claude Pache wrote: >> >> The proposed modification of `function_exists()` will break existing code: > >Please can you submit a failing test to >https://github.com/Girgias/php-src/tree/zend_autoloader that shows a

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Dan Ackroyd
On Wed, 12 Apr 2023 at 17:32, Claude Pache wrote: > > The proposed modification of `function_exists()` will break existing code: Please can you submit a failing test to https://github.com/Girgias/php-src/tree/zend_autoloader that shows a BC break. cheers Dan Ack -- PHP Internals - PHP Runtime

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Rowan Tommins
On 12/04/2023 17:31, Claude Pache wrote: * keep the current semantics, that using a namespaced or qualified function name, (including a function name given as string, which is implicitly fully qualified), doesn’t fall back to the global scope, — even when a previous use of the same function

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Claude Pache
> Le 10 avr. 2023 à 14:17, G. P. B. a écrit : > > Hello Internals, > > Dan and I would like to propose a new core autoloading mechanism that fixes > some minor design issues with the current class autoloading mechanism and > introduce a brand-new function autoloading mechanism: >

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Anton Smirnov
On Tue, 2023-04-11 at 11:57 +0100, G. P. B. wrote: > No, array_map will trigger the autoloader (actually strlen() will > trigger it once first) and the autoloader should then load the > array_map function from the My namespace. > However, if the autoloader does not correctly load the

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Dan Ackroyd
On Tue, 11 Apr 2023 at 18:12, Hans Krentel via internals wrote: > > So I'd love to see some commentary on a `function_alias()` > if now function autoloading is considered to come in I wouldn't be opposed to it, but it should be a separate RFC. The implementation could be copied from

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Dan Ackroyd
On Wed, 12 Apr 2023 at 09:24, Nicolas Grekas wrote: > > I would like to see a similar benchmark with function autoloading enabled. > https://github.com/phpbenchmarks/ Can you point me to where one can tell the benchmark framework to use a custom version of PHP? > One of the big differences

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Rowan Tommins
On Wed, 12 Apr 2023 at 09:24, Nicolas Grekas wrote: > > To me, class autoloading is a performance feature. If we didn't care about > performance, we would be fine with eagerly loading a bunch of classes as > e.g. Java does. I think (class) autoloading actually serves two purposes: as you say,

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-12 Thread Nicolas Grekas
Hello George, Dan and I would like to propose a new core autoloading mechanism that fixes > some minor design issues with the current class autoloading mechanism and > introduce a brand-new function autoloading mechanism: > https://wiki.php.net/rfc/core-autoloading > > The existing SPL

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Hans Krentel via internals
On Monday 10 April 2023 14:17:04 (+02:00), G. P. B. wrote: > Hello Internals, > > Dan and I would like to propose a new core autoloading mechanism [...] > > The existing SPL autoloading functions would become aliases to the new Core > ones and will continue to work without any migrations

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Rowan Tommins
On 11 April 2023 13:21:08 BST, Mark Baker 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

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Rowan Tommins
On 11 April 2023 13:01:08 BST, Dan Ackroyd wrote: >On Tue, 11 Apr 2023 at 09:48, Rowan Tommins wrote: >> >> Similarly, I think it should be possible to "unpin" a function >> lookup with a later definition, > >Can you say what the technical justification for that is? Perhaps "should" is too

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Dan Ackroyd
On Tue, 11 Apr 2023 at 08:14, Michał Marcin Brzuchalski wrote: > > Can we improve the RFC with a short description of issues on SPL autoload > this RFC tries to address? Sure, if you want to propose some clearer words than these: "The spl_autoload_register() does not become an alias for

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Kamil Tekiela
> > We have the special constants like \MyNamespace\MyClass::class. Would > you envisage (or is there value in) equivalent constants like > \MyNamespace\MyFunction::function? > If anything, I would suggest renaming the existing constant to something more meaningful. There is no point in adding

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Mark Baker
On 10/04/2023 14:17, G. P. B. wrote: Dan and I would like to propose a new core autoloading mechanism that fixes some minor design issues with the current class autoloading mechanism and introduce a brand-new function autoloading mechanism: https://wiki.php.net/rfc/core-autoloading The existing

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Dan Ackroyd
On Tue, 11 Apr 2023 at 09:48, Rowan Tommins wrote: > > Similarly, I think it should be possible to "unpin" a function > lookup with a later definition, Can you say what the technical justification for that is? There's reasons why (imo) it's probably wrong, but I don't currently understand what

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Rowan Tommins
On 11 April 2023 12:16:18 BST, "G. P. B." wrote: > >However, we *already* do function pinning which can result in this >behaviour via the function cache, see the following bug which defines a new >function via eval(): >https://bugs.php.net/bug.php?id=64346 That's not the same thing - that's

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Sara Golemon
> On Apr 10, 2023, at 07:17, G. P. B. wrote: > > Hello Internals, > > Dan and I would like to propose a new core autoloading mechanism that fixes > some minor design issues with the current class autoloading mechanism and > introduce a brand-new function autoloading mechanism: >

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread G. P. B.
On Tue, 11 Apr 2023 at 09:48, Rowan Tommins wrote: > > As a result of the pinning, function_exists() will return true for > functions in namespaces that have been pinned to a global function. > > The lookup pinning seems like the right way to optimise the > implementation, but I don't think it

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread G. P. B.
On Mon, 10 Apr 2023 at 20:12, Anton Smirnov wrote: > Hello George, > > I'm not sure I'm 100% correct but I think that this RFC still allows to > call different functions for the same code, just not in the same run. > > Consider this pseudocode: > > //- funcs.php > > namespace My; > > function

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Rowan Tommins
On 10 April 2023 13:17:04 BST, "G. P. B." wrote: >Hello Internals, > >Dan and I would like to propose a new core autoloading mechanism that fixes >some minor design issues with the current class autoloading mechanism and >introduce a brand-new function autoloading mechanism:

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Michał Marcin Brzuchalski
Hi George and Dan, pon., 10 kwi 2023 o 14:17 G. P. B. napisał(a): > Hello Internals, > > Dan and I would like to propose a new core autoloading mechanism that fixes > some minor design issues with the current class autoloading mechanism and > introduce a brand-new function autoloading

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-10 Thread Anton Smirnov
Hello George, I'm not sure I'm 100% correct but I think that this RFC still allows to call different functions for the same code, just not in the same run. Consider this pseudocode: //- funcs.php namespace My; function myfunc(...) { ... } function array_map(...) { ... } //- code1.php

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-10 Thread Deleu
On Mon, Apr 10, 2023 at 10:01 AM Ondřej Mirtes wrote: > I don’t like the proposed function names: > > autoload_register_class to me reads like “register this class for > autoloading”. If I observe the intended meaning correctly, it should be > called “register_class_autoloader”. > > Same for

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-10 Thread Aleksander Machniak
On 10.04.2023 14:17, G. P. B. wrote: Hello Internals, Dan and I would like to propose a new core autoloading mechanism I think it would make a lot of sense to have one function for all kind of features, but the user should define which ones. For example: Loader::register(callable

Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-10 Thread Ondřej Mirtes
I don’t like the proposed function names: autoload_register_class to me reads like “register this class for autoloading”. If I observe the intended meaning correctly, it should be called “register_class_autoloader”. Same for autoload_register_function - better name would be

[PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-10 Thread G. P. B.
Hello Internals, Dan and I would like to propose a new core autoloading mechanism that fixes some minor design issues with the current class autoloading mechanism and introduce a brand-new function autoloading mechanism: https://wiki.php.net/rfc/core-autoloading The existing SPL autoloading