Re: [PATCH] bracketed namespace declarations

From: Date: Fri, 07 Nov 2008 21:53:54 +0000
Subject: Re: [PATCH] bracketed namespace declarations
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-41769@lists.php.net to get a copy of this message
Stan Vassilev | FM wrote: > <?php > // global, scope 1 > > namespace { // global, scope 2 } > > // global, scope 1 > > namespace { // global, scope 3 } > > // global, scope 1 > > namespace foo\bar { // foo\bar, scope 4 } > > // global, scope 1 > ?> I am afraid I must shed my generally congenial public nature to express a strong opinion: This is a horribly complex idea Stan. PHP's implementation of namespaces do not define scope. Once we open that Pandora's box, there is no turning back. Big time -1 from me. Remember, the patch I'm proposing would only be necessary for people using un-namespaced code combined with namespaced code (already a bad idea) *and* scattering "use" statements throughout the global code. Also, the *only* supported use case behind allowing multiple namespaces per file is to allow people to mash pre-existing separate PHP files together, and have them still compile. Requiring brackets is designed to make it more readable, and the "use" restriction furthers that goal. I would have implemented this requiring all code to be encased in namespace {} or namespace nsname {}, but that turned out to be virtually impossible in the parser because of the need to also allow "declare" statements outside namespace declarations Thanks, Greg

« previous php.internals (#41769) next »