> Now the behaviour of my program can completely change depending on which of
> those functions I call first, which might even depend on user input.
> Regardless of exactly how the cache works, that kind of unpredictability is
> a recipe for disaster.

It already does completely change depending on user input, without autoloading, 
in the same way.
I assume you're arguing against autoloading without autoloading \NS\strlen 
every time,
but I still consider the approach I'm proposing an improvement over existing 
unpredictable behavior.

> The only way to make it predictable again is to pre-define the namespaced
> function in my startup code, at which point I don't need function
> autoloading.

Other use cases would benefit from function autoloading, though.
The use case in your example is very different from the common use case I
have in mind for proposing autoloading - name reuse should be uncommon in 
practice.
Adding "use NS\strlen", "namespace\strlen", etc. are alternatives to make it 
predictable
I'd consider reusing the name from the global namespace intentionally to be a 
code smell.
Overlap might be unavoidable for common names such as \NS\run() in some 
libraries,
but hopefully they'd preload the entire file of functions for those,
or be in a different namespace from the code using those libraries,
and other libraries (e.g. polyfills in global namespace) could still use 
autoloading.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to