Re: [RFC] Function autoloading through spl_autoload*
| From: | Sebastian Krebs | Date: | Sun, 14 Aug 2011 20:47:53 +0000 |
| Subject: | Re: [RFC] Function autoloading through spl_autoload* | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-54595@lists.php.net to get a copy of this message | ||
Hi,
Am 14.08.2011 15:55, schrieb Derick Rethans:
On Sat, 6 Aug 2011, Ferenc Kovacs wrote:For the same reasons, why class-autoloading is useful: Loading when needed and avoiding unnecessary repetitive include-statements.I would like to introduce this RFC which would provide function autoloading through the spl_autoload facility without userland BC breakage. https://wiki.php.net/rfc/autofuncI understand the proposal, but I don't see any compelling reasons in the RFC of why we actually need autoloading for functions?
For classes it makes sense because there is almost always a class to file mapping. For functions (and constants) that is not the case, so I am wondering how useful this function autoloading actually is.Like classes there may be also a function-to-filename-mapping, especially now, since namespaces exists. It is very easy to extend the PSR-0 standard (lets say: PSR-0.1 ;)) so functions and constants are covered by it too: - Constants and functions are in a file named after the namespace myNamespace\foo\bar => MyNamespace/foo/bar.php When class-autoloading were introduced there were no ^real^ class-to-file-mapping too. You had to define it yourself the time, when you wrote your
__autoload()-function. It's nearly the same with functions/constants now, except that we are away from a single function and that there are already ideas, that may cover such mappings already.
Or in my words: I don't see _any_ reason, why function-/constant-autoloading does _not_ exists ;)
cheers, DerickRegards, Sebastian