Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32928 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22152 invoked by uid 1010); 23 Oct 2007 04:42:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 22137 invoked from network); 23 Oct 2007 04:42:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2007 04:42:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:48961] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/41-13350-0CB7D174 for ; Tue, 23 Oct 2007 00:42:41 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id E4ED0C0F93F; Mon, 22 Oct 2007 21:42:37 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-13-199.neb.res.rr.com [76.84.13.199]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 5BD8DC0F93E; Mon, 22 Oct 2007 21:42:37 -0700 (MST) Message-ID: <471D7CA6.5050108@chiaraquartet.net> Date: Mon, 22 Oct 2007 23:46:30 -0500 User-Agent: Thunderbird 1.5.0.13 (X11/20070824) MIME-Version: 1.0 To: Stanislav Malyshev CC: Chuck Hagenbuch , 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> <20071021203755.11105vn0ycds6bs4@technest.org> <471D4623.4090208@zend.com> <20071022235530.82912k3mlfz2ajsw@technest.org> <471D764C.1080004@zend.com> In-Reply-To: <471D764C.1080004@zend.com> X-Enigmail-Version: 0.94.2.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [PHP-DEV] Order of class resolution with namespaces and autoload From: greg@chiaraquartet.net (Gregory Beaver) Stanislav Malyshev wrote: >> namespace Foo; >> import Exception; > > Once more, import with one-term argument is a no-op. And will stay so. > That's why we have the warning. > >> I think that either import ::Exception needs to work, or import >> Exception shouldn't issue a warning. > > We'll discuss this one. I wonder if anybody else feels a need for it? One of the nice features of import is that we will be able to take older code, plop a namespace declaration at the top of the file and a few imports and without recoding anything have full access to class names, i.e. refactoring class names without actually having to touch the code. As such, this may mean aliasing top-level classes to another name. I don't have a specific example off the top of my head, but I hope this makes sense. >> I think you need to envision working in a large team on a large >> project here, but you may simply not see the need. > > I'd say if you have large team which has a possibility of having > classes with same names running into each other, why not having them > reside in different namespaces? After some reflection, I think the only use case would be in an autoload implementation. If an unknown class is simply used, the executor assumes you want the current namespace. The only way around this is to do something like "import Classname as Classname;" which seems kind of silly. Another possibility for all of this would be to have "use" trigger autoload if the class doesn't exist, as a runtime option. "import" could be a non-autoloading version of the same thing. i.e.: would trigger autoload for Burp::Exception and Burp::thing and fatal error if the class can't be loaded, and simply alias "Burp::another" to "another" in the script. This may be too much, I'm on the fence on its utility, but it would provide a more abstract way of triggering a friendly error message if a class is not found, something like "class Burp::Exception was not found, and could not be autoloaded (include_path=".:/whatever")". Greg