> I've asked this question for a while (one, or two years ago or so). > Must say, that I didn't remember the answer, but I would like to see > autoloading for namespace-constants and functions too :)
I proposed extending the autoload mechanism to functions and constants several times since I released Automap. Automap (http://automap.tekwire.net) is a map-based PHP autoloader. It includes a source scanner which analyzes source files and builds a map file from the symbols it finds. This process already registers functions and constants, as well as classes. So, it is ready to resolve functions and constants (and it was recently improved to support namespaces). After I released Automap (back in 2006 !), I had planned to finish the work, i.e. create new hooks in the PHP core to autoload undefined functions/constants. Unfortunately, when I proposed this on the list, the reaction was mostly negative and the proposal was rejected. IMO, it comes from a misconception about autoloaders, as most autoloaders are path-based, and such a mechanism imposes a restriction of one symbol per file, which makes it useless in practice for functions and constants. So, the idea of extending the autoload *features* was rejected because of current autoloader *implementations*. There may also be a global feeling among core devs that non-OO programming belongs to the past and shouldn't be encouraged... I hope you find more support on this than I had. Technically speaking, it would be easy to extend autoloading to functions and constants. It can even be done without BC breaks, combining 'old-style' and 'new-style' autoloaders without ambiguity (adding a second argument to the autoload hook, and checking the number of args declared by the function). A summary of the talk we had (6 years ago !) : http://devzone.zend.com/616/zend-weekly-summaries-issue-306/ Regards François -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php