Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20968 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42191 invoked by uid 1010); 1 Dec 2005 17:07:52 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42176 invoked from network); 1 Dec 2005 17:07:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2005 17:07:52 -0000 X-Host-Fingerprint: 84.60.26.23 dslb-084-060-026-023.pools.arcor-ip.net Received: from ([84.60.26.23:4312] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 21/3C-14828-7ED2F834 for ; Thu, 01 Dec 2005 12:07:51 -0500 Message-ID: <21.3C.14828.7ED2F834@pb1.pair.com> To: internals@lists.php.net Date: Thu, 01 Dec 2005 18:07:47 +0100 User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 References: <23057.137.224.252.10.1133455342.squirrel@www.mediawave.nl> In-Reply-To: <23057.137.224.252.10.1133455342.squirrel@www.mediawave.nl> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Posted-By: 84.60.26.23 Subject: Re: Desired namespace behavoir From: oliver.graetz@arcor.de (=?ISO-8859-1?Q?Oliver_Gr=E4tz?=) Bart de Boer schrieb: > namespace JessieStuff { > class FirstClass { ... } > class SecondClass { > public $obj; > function __construct() { > $this->obj = new FirstClass(); > } > } > } > > Now we'd import this with prefixing everything and the > result would be something that acts like: > > class JessieStuff_FirstClass { ... } > class JessieStuff_SecondClass { > public $obj; > function __construct() { > $this->obj = new FirstClass(); > } > } > > Then, if I do: > $x = new JessieStuff_SecondClass(); > > I'd get an error that 'FirstClass' can't be found. Because it's > renamed to JessieStuff_FirstClass. Nope. First of all, using FirstClass INSIDE the namespace would always prefer using the own namespace. Local definitions override global definitions (see http://en.wikipedia.org/wiki/XML_namespace ). And then, the class is hopefully NOT renamed but aliased: namespace a { class A1 {} class A2 { protected $m=null; protected $n=null; public function __construct() { // should both work $this->m=new A1(); $this->m=new a:::A1(); } } } $x=new a:::A2(); import namespace a; $y=new A2(); // should work after import import a:::A2 as Foo; $z=new Foo(); // should work, A2 locally knows A1 $yikes=new a_A2(); // should work with auto_import_prefix set to on > Or do you suggest we replace all occurences of 'new ClassName()' to > 'new JessieStuff_ClassName()' as well? Occurences where? > Or do you suggest that everything that was inside the namespace is > still able to call "internal" classes without using the namespace > prefix? And your INI option only provides interface classes? This is part of the definition of namespaces. And yes, I want the INI option to just provide aliases. If these are implemented by injecting class a_A2 extends a::A2 {} as interface classes or by internally providing a hash table alias is only different from a technical point of view. The result would be the same, the performance would probably better using the alias. OLLi