How bad would it be to say that namespacing can only apply to classes and
not normal functions?

Lame, very lame. It would make them unusable for many distributed projects that are not 100% OOP. Wordpress comes to mind. My own Phorum as well.


I agree, namespaces need to work for all definition types.
I don't see a problem here:

1) ns1::ns2::class::static() and ns1::ns2::namespace::func() is a collision 2) why is it a collision? because we have a class and subnamespace in the same namespace, with the same names.
3) solution therefore is to NOT allow this collision, and end with an error.

[Example 1]

namespace a::b::c;
function foo() {}

namespace a::b;
class c {} // FATAL ERROR: class collision with existing namespace "a::b::c"

[Example 2]

namespace a::b;
class c {}

namespace a::b::c; // FATAL ERROR: namespace collision with existing class "a::b::c"
function foo() {}

So now, while the syntax may still be ambiguos if a codeline is cut and pasted alone in a blank text file, at least *in context* it can do only one thing: call whatever the user defined/imported/included. If there's a collision, he'll see the error, and take action.

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

Reply via email to