Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33921 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66621 invoked by uid 1010); 11 Dec 2007 09:20:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 66606 invoked from network); 11 Dec 2007 09:20:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2007 09:20:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=mp@webfactory.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mp@webfactory.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain webfactory.de from 195.227.108.51 cause and error) X-PHP-List-Original-Sender: mp@webfactory.de X-Host-Fingerprint: 195.227.108.51 wfserver02.wf-ppr.de Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222) Received: from [195.227.108.51] ([195.227.108.51:11547] helo=wfserver02.wf-ppr.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/30-60949-4465E574 for ; Tue, 11 Dec 2007 04:20:05 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Tue, 11 Dec 2007 10:20:01 +0100 Message-ID: <00A2E2156BEE8446A81C8881AE117F199A0721@companyweb> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: AW: [PHP-DEV] Namespace resolution Thread-Index: Acg71HMzrCXzlB3QSoKqdDv1Ta5FegAAIfcQ References: <11970653983080000@9866357972520000.9866341568840000> <475BDDF1.7040605@ctindustries.net> <1723341090.20071210220025@marcus-boerger.de> <1197323296.3922.5.camel@sbarrow-desktop> <00A2E2156BEE8446A81C8881AE117F199A0715@companyweb> To: =?iso-8859-1?Q?David_Z=FClke?= Cc: "Sam Barrow" , Subject: AW: AW: [PHP-DEV] Namespace resolution From: mp@webfactory.de ("Matthias Pigulla") > Von: David Z=FClke [mailto:dz@bitxtender.com] > The problem I see with that is that if I have an application that uses > a 3rd-party library which does not use namespaces, I need to > use ::LibClass everywhere. Until they switch to namespaces - then I > need to touch hundreds and thousands lines of code. If LibClass were > looked up in the global namespace, too, I could simply add the > appropriate import statements at the top of each file. You got a point. > Anyways, the process you described seems flawed in another fashion: It > looks up a class in the namespace first, then an internal php class, > then it tries an autoload. That does not make sense. Lets say I run > some code as you described, and there is a class C(), but it's not > been autoloaded yet. The internal class C is used. Then, later, the > autoloading of A::B::C() is somehow forced. Now, if the same code runs > again, a different class is used. That sounds like nonsense. Exactly what Chuck and Greg tried to point out, providing examples for = what you describe. http://www.mail-archive.com/internals@lists.php.net/msg31217.html In my opinion one of the biggest weak points. In order to make things = work consistently and reliable (behaviour does not change because of the = order in which files are included or because new core classes are = added), you need to 1) make sure all the stuff you use is already known = (that is, refrain from using __autoload and revert to require() at the = top of your files) or 2) explicitly use/import all your classes, even = the ones from your namespace inside your namespace. That is because __autoload comes after internal classes (which comes = after already known classes from the current NS) for unqualified names. = Approach 1) makes the names "already known", 2) turns the unqualified = names into qualified ones by means of aliasing. :( -mp.