Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32906 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35379 invoked by uid 1010); 22 Oct 2007 00:38:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35364 invoked from network); 22 Oct 2007 00:38:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2007 00:38:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=chuck@horde.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=chuck@horde.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain horde.org designates 66.92.78.250 as permitted sender) X-PHP-List-Original-Sender: chuck@horde.org X-Host-Fingerprint: 66.92.78.250 dsl092-078-250.bos1.dsl.speakeasy.net Received: from [66.92.78.250] ([66.92.78.250:46896] helo=technest.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/86-32256-6E0FB174 for ; Sun, 21 Oct 2007 20:38:01 -0400 Received: by technest.org (Postfix, from userid 33) id DEB8A7F00D; Sun, 21 Oct 2007 20:37:55 -0400 (EDT) Received: from tatiana (tatiana [192.168.1.2]) by technest.org (Horde Framework) with HTTP; Sun, 21 Oct 2007 20:37:55 -0400 Message-ID: <20071021203755.11105vn0ycds6bs4@technest.org> Date: Sun, 21 Oct 2007 20:37:55 -0400 To: Stanislav Malyshev Cc: internals@lists.php.net References: <20071019224202.20245u5zry52h5c8@technest.org> <471A6B32.3080401@zend.com> <20071020172658.1680416b83wxgv6s@technest.org> <471A7C88.6090904@zend.com> <20071020184554.69044keujpgfelus@technest.org> <471A8A12.3050407@zend.com> <20071020191948.19935z9hoqcn9c84@technest.org> <471A9049.1020408@zend.com> <20071020194217.98794nbyt3bwrlnk@technest.org> <471AEF26.5000601@zend.com> <20071021105124.85283gxiqqx9zse8@technest.org> <471BA74C.1040103@zend.com> In-Reply-To: <471BA74C.1040103@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.2-cvs) Subject: Re: [PHP-DEV] Order of class resolution with namespaces and autoload From: chuck@horde.org (Chuck Hagenbuch) Quoting Stanislav Malyshev : > I'm not sure I follow you. If you intend to always use internal one, =20 > why you define the local one? If you sometimes intend to use one and =20 > sometimes another - I propose you a way to ensure the right one is =20 > always used, this without using potentially long full name. I must =20 > be missing something here - can you specify what exactly you want it =20 > to be? You do understand that if you insist on always using =20 > unqualified name, it must work some consistent way, and this way can =20 > not satisfy all possible scenarios because they are contradictory? Yes. I think that if you use an unqualified name it should always be =20 relative to the namespace (and importing internal classes into your =20 namespace lets you use short names for them, avoiding ::Exception). >> This unpredictability is I think the worst part of the current =20 >> implementation. > > There's no "unpredictability" - the behavior is entirely =20 > predictable, you just don't like it :) That's like saying that =20 > function call is unpredictable, because if you don't define the =20 > function it produces an error. Here is what I mean: 1.php ----- name conflict, which seems correct import Exception as Error; -> Fatal error: Import name 'Error' conflicts with defined class in =20 /Users/chuck/Desktop/php namespaces/2.php on line 4 (this I don't understand) import ::Exception as Error; -> parse error (can't import a top-level class name that way) Therefore, in my mind, in order to write durable code that will not =20 break no matter what other classes other developers define or import, =20 I should always prefix builtin classes with ::. Given this, the only difference between how I think things should work =20 is that I think that, when I have declared a namespace, I should be =20 able to rely on any short name referring to that namespace or one of =20 my explicit imports. The key being that _I_ declared that namespace =20 and the imports and they will affect only that file, so I am =20 completely in control of what name means what. The way things currently are, using a shortname means look inside the =20 namespace, UNLESS there's a builtin class with the same short name and =20 the namespaced version hasn't been autoloaded yet, or there's an =20 explicit import... I really think it's unintuitive that when you declare a namespace =20 names don't necessarily refer to that namespace. It doesn't match =20 other languages, either - you always need to import classes/names if =20 you want to use short names for functionality outside your =20 namespace/package/etc. Sincerely, -chuck