This is tangential to the function autoload discussion. An idea that popped into my head an hour ago, that I don't have another PHP Dev to talk to about, what if you could register a function that is called by PHP the first time it sees a namespace declared?
This would allow functions and for that matter constants of the namespace to be declared before they get called. It isn't as clean as waiting until the function call itself is being called, but maybe that's for the best. After all, if you have a dozen 10 line utility functions do you necessarily want 10 files. Again, I don't know the engine, but this doesn't seem like this would be that hard to do. Note that how autoloaders register themselves to this function, resolve what to load and so on is a separate can of worms. As to what to call it, maybe spl_namespace_register($callback, $prepend). The callback gets the string of the namespace that PHP just saw for the first time and it gets to execute before any code in that namespace gets to execute. Thoughts?
