2013/5/2 Igor Wiedler <[email protected]>
> No, I want to keep autoloading out of this proposal. It is way beyond the
> scope of the namespacing issue and also incredibly complex.
>
> That said, this RFC may be useful for implementing autoloading in the
> future, as it addresses one of the things that makes function autoloading
> hard, which is being able to distinguish between namespaced and global
> function calls. But that's only one piece of the puzzle.
>
Well, it is not as complex as it sounds
This is the behaviour right now
- Does X exists as namespaced function (current namespace or imported)?
- Does X exists as global (builtin) function?
- Trigger error
The behaviour including autoloading would be more like
- Does X exists as namespaced function (current namespace or imported)?
- Does X exists as global (builtin) function?
- Trigger autoload
- Does X exists as namespaced function (current namespace or imported) now?
- Maybe: Does X exists as global function now?
- Trigger error
The autoloading itself could use parts already used for class-autoloading.
// Signature
// spl_autoload_register($callback[, $type = AUTOLOAD_CLASS]);
$autoload = function ($name, $type = AUTOLOAD_CLASS) {
// Do something
};
spl_autoload_register($autoload, AUTOLOAD_CLASS | AUTOLOAD_FUNCTION |
AUTOLOAD_CONSTANT); // "constant" here just to make it complete
Namespaced functions without autoloading seems kindof incomplete,
especially because it isn't such a big deal to simply use the prefixed one,
so the benefit seems quite small to me :X
use MyFoo\Bar\MathFunctions as math;
$x = math\sin($y);
Just saying :)
Regards,
Sebastian
>
> On May 2, 2013, at 11:40 PM, Sebastian Krebs <[email protected]> wrote:
>
> > Hi,
> >
> > Are you going to cover autoloading of functions too?
> >
> > Regards,
> > Sebastian
>
--
github.com/KingCrunch