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

From: Date: Thu, 26 Jun 2008 15:57:25 +0000
Subject: Re: How bad would it be to say/enforce that namespacing can only apply to classes and not normal functions?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-38639@lists.php.net to get a copy of this message
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.

« previous php.internals (#38639) next »