Re: phpnamespaces.org!

From: Date: Fri, 02 Dec 2005 16:43:28 +0000
Subject: Re: phpnamespaces.org!
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-21011@lists.php.net to get a copy of this message
Hello Ron, ""Ron Korving"" <r.korving@xit.nl> wrote in message news:8F.C6.14828.4DAFF834@pb1.pair.com... > I assume ::: is being used because it simply works and the discussion on > which seperator to use might still go on for some time ;). You have a point > about import statements being allowed only in the beginning. This would be > nice: > > class X > { > public function foo() > { > import class bar:::MyClass; > $obj = new MyClass(); > $obj->doSomething(); > } > } > > This would be nice, because __autoload() only needs to be called if my > method foo() is being called. bar:::MyClass is not a dependency for the > whole file, but only for X::foo(). Performance-wise it would be a good thing > if importing namespaces would not extend the dependency to the whole file. > Also, it could prevent unnecessary aliasing: > __autoload is not called at the time of import, only when the alias is actually used, so there are actually no performance issues here. > class X > { > public function foo() > { > import class bar:::MyClass; > $obj = new MyClass(); > $obj->doSomething(); > } > > public function fubar() > { > import class bla:::MyClass; > $obj = new MyClass(); > $obj->doSomething(); > } > } > > In this example, bar:::MyClass and bla:::MyClass are used. Two different > classes, each in their own namespace. Aliasing is not required, because the > imported namespaces are limited to the scope of the methods foo() and > fubar(). > Do we really want this? Since there is no performance improvement having imports be block-scoped, this really is not needed. IMO, it can also create confusion, as the same alias means different things in different contexts of the file. Regards, Jessie

« previous php.internals (#21011) next »