> If we cache the resolution to global function at line 2, removing that line
> changes the rest of the program. If we don't cache it there, then what
> happens if we run this code in a loop?

It (and my proposed autoloader change)
changes it for that call (at that opcode, i.e. for the call at that line and 
column).
PHP's caching does not cache it for other calls within the same file.
If that call opcode was within a function or loop, however,
subsequent calls would use the cached resolution.

> namespace Foo;
> echo strlen('hello'); // Finds a global function at step 2, so doesn't
> trigger the autoloader
> echo \Foo\strlen('hello'); // Explicitly namespaced function, so triggers
> the autoloader
> echo strlen('hello'); // Should this run \strlen or Foo\strlen?

The example you were thinking of would call \strlen on line 2, \Foo\strlen on 
line 3, and \Foo\strlen on line 4.
(because the caching is per-opcode, not per-file or per-namespace)

> We've never prioritized fixing this issue,
> but implementing the proposed autoloading behavior would make fixing it 
> essentially impossible, as we certainly can't perform an autoloader 
> invocation on each call.

If we skip autoloading ambiguous calls in the current namespace,
then we wouldn't have to perform an autoloader invocation every call,
and the problem of fixing that bug would be unchanged.
I marked step 3 as optional because there were arguments for/against it.

-Tyson
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to