On 17 June 2026 11:03:07 BST, Anton Smirnov <[email protected]> wrote:
>Imagine we have an old guzzle/psr7 with stream_for function, and they use it 
>without a qualifier. I defined a global stream_for so now I hijacked the 
>internal library logic. Is it correct?
>
>The previous attempt with namespace pinning made more sense to me


The concern that occurred to me is similar: if I rely on function autoloading, 
but forget to fully-qualify a name in the current namespace, it would 
accidentally work as long as some other code triggered loading of that function 
first. Then some small refactoring - or even a different path through the code 
at runtime - and it will silently fall back to a function in the global 
namespace instead.

I think if autoloading is going to require some extra "ceremony" in the code, 
it would be preferable to have a declare() at the top of the file forcing the 
interpretation of all unqualified names (either "always assume current 
namespace" or "always assume global namespace"). That way, code would not 
change behaviour based on hard-to-predict side effects elsewhere. 



Rowan Tommins
[IMSoP]

Reply via email to