On 29/01/2017 17:56, Wes wrote:
Hi Rowan, I probably wasn't clear enough. How is having to write
use namespace Foo\Bar\Baz;
better than
require_once("../Foo/Bar/Baz/functions.php");
OK, your last question just mentioned putting multiple functions in one
file, not that you were addressing that particular proposal. Those are
very different parts of the conversation. In an ideal world, just
calling "\Foo\Bar\Baz\frobnicate()" would trigger an autoloader, and
that autoloader could decide to require_once one big file if that's what
the library author wanted.
To an extent, I agree that requiring you to import a namespace in order
to autoload it is perhaps too much of a compromise. There is some
advantage over a plain require_once, though, in that you don't need to
hard-code into your application the directory layout of some other
library; it would be more akin to having a global function like
"load_function_definitions($namespace);"
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php