On 18/07/2016 01:50, Stanislav Malyshev wrote:
Hi!

How about an alternative approach where a function inside a namespace
can be autoloaded using the existing callback, by using a reserved
namespace segment? So to autoload function "foo\bar()", the engine would
construct a string like "__function\foo\bar" or "foo\__function\bar",
and pass that to the registered autoloader stack.

Magic out-of-domain values usually are bad design, and lead to a lot of
trouble since now the system needs to deal with two sets of assumptions
instead of one. I wouldn't recommend doing it.


Hi Stas,

My original idea was actually to have the autoloader look up "foo\bar\__functions" for *any* function in namespace "foo\bar", with the idea that some existing autoloaders would actually be able to work without any modification (just call your file "__functions.php").

If you include the function name (to give users more flexibility), that doesn't really work (unless you have one function per file), so you're right that it requires some muddling assumptions.

I agree that it's all a bit magic either way, but I thought it might get the feature moving quicker than a complete rewrite of the existing autoload system.

Like I say, it was just an idea. :)

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to