Hi Dan,

(Thanks for your patience while waiting on my reply.)


> On Jun 20, 2026, at 07:18, Dan Ackroyd <[email protected]> wrote:
> 
> I've very much in favour of autoloading.  Please can you address Bob's 
> concern:

Replied, and (I hope) addressed -- I'm sure he will say if not.


> I've also previously been involved in an RFC attempt for function 
> autoloading. I'm pretty certain that I came to the conclusion that for this 
> edge case; that the function autoloader needed to be called twice to have the 
> least surprising behaviour.

Does the suggestion of `declare(strict_namespace=1)` (suggested in various 
forms by others as well), to disable the global fallback on unqualified 
function and constant names, sound like a reasonable alternative?


> btw I don't think the RFC makes a strong case for why it is beneficial - 
> which keeps the RFC text short, but might leave people wondering why it is 
> needed. Some people don't see that function loading is useful (in exactly the 
> same way people didn't think class autoloading was useful) and so aren't 
> prepared to accept any trade-off. There is an overlapping problem of people 
> who are not maintainers pooh-poohing ideas just because they don't personally 
> want to use them.

Fair enough -- I did want to keep it short, but I can add some "motivation" 
narrative. I see your notes appended, I will incorporate them as I am able.

As long as we're here:

One of the early steps in the [MLAPHP][] process is to convert functions to 
static class methods. The idea is *not* to make the code "object- or 
class-oriented" but to make it "autoloadable." Doing so means you can get rid 
of include statements, thereby removing any side effects that might come 
includes. This makes the logical flow more comprehensible.

This conversion process is tedious and time consuming, even with artificial 
assistance. It would be much better if the functions could be autoloaded 
directly, and the include statements removed without having to do a conversion. 
The functions could be moved to an autoloadable location, leaving only 
side-effects (if any) in the included files. The whole refactoring process 
becomes much more tractable.

So in a way, a big motivation is "get rid of as many include statements as 
possible".


-- pmj


[MLAPHP]: https://leanpub.com/mlaphp

Reply via email to