Re: Idea: Function autoloading using dummy namespaces
| From: | Jesse Schalken | Date: | Mon, 18 Jul 2016 04:18:50 +0000 |
| Subject: | Re: Idea: Function autoloading using dummy namespaces | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94545@lists.php.net to get a copy of this message | ||
On Mon, Jul 18, 2016 at 4:53 AM, Nikita Popov <nikita.ppv@gmail.com> wrote:
>
> Option B: foo() in namespace Bar will
> a) Check if Bar\foo() exists
> b) Otherwise check if foo() exists
> c) Otherwise try to load 'Bar\foo'
> d) Otherwise try to load 'foo'
> e) If all fails, throw.
>
> This avoids the autoloading overhead when calling functions from the global
> namespace. However this also means that you cannot autoload a function with
> the same name as a global function through an unqualified call.
>
>
Doesn't this mean that an innocent introduction of global function "foo()"
could break "namespace Bar { foo(); }", since it would then refer to the
global function "foo" (step b) and "Bar\foo" would not be autoloaded (step
c)?