Hi,
Am 14.08.2011 15:55, schrieb Derick Rethans:
On Sat, 6 Aug 2011, Ferenc Kovacs wrote:
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/autofunc
I understand the proposal, but I don't see any compelling reasons in the
RFC of why we actually need autoloading for functions?
For the same reasons, why class-autoloading is useful: Loading when
needed and avoiding unnecessary repetitive include-statements.
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,
Derick
Regards,
Sebastian
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php