Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31954 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27082 invoked by uid 1010); 28 Aug 2007 12:14:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27067 invoked from network); 28 Aug 2007 12:14:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Aug 2007 12:14:14 -0000 Authentication-Results: pb1.pair.com header.from=dz@bitxtender.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dz@bitxtender.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitxtender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: dz@bitxtender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:44714] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/4C-44152-39114D64 for ; Tue, 28 Aug 2007 08:14:12 -0400 Received: from [87.79.35.58] (helo=[192.168.0.164]); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1IPzxQ-0001us-PB; Tue, 28 Aug 2007 14:14:08 +0200 In-Reply-To: <46D30EA2.7080406@zend.com> References: <000f01c7e871$9be827e0$6e02a8c0@thinkpad> <46D30EA2.7080406@zend.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: <275A466F-5E0E-4DC6-82F2-BBBD4260E0B5@bitxtender.com> Cc: Dmitry Stogov , 'PHP Internals List' Content-Transfer-Encoding: 7bit Date: Tue, 28 Aug 2007 14:14:06 +0200 To: Stanislav Malyshev X-Mailer: Apple Mail (2.752.2) X-bounce-key: webpack.hosteurope.de;dz@bitxtender.com;1188303252;9de4b33a; Subject: Re: [PHP-DEV] Namespaces and __autoload() From: dz@bitxtender.com (=?ISO-8859-1?Q?David_Z=FClke?=) Why don't we add an optional second argument to __autoload() that receives the fully qualified namespace name of the class that should be autoloaded? That doesn't break BC and it prevents conflicts. David Am 27.08.2007 um 19:49 schrieb Stanislav Malyshev: >> > namespace Foo; >> throw new Exception; >> In this case PHP first looks for Foo::Exception and only then for >> internal >> Exception, but the first lookup may call __autoload (or >> corresponding SPL >> functions) and it can emit error or throw exception. >> The patch provides an additional boolean argument to __autoload() >> that say >> if class is really required. In case if it false, user code >> shouldn't emit >> errors or throw exceptions. > > There's two problems here: > 1. On each access to internal class, like Exception, SPL classes, > DateTime, reflection classes, etc. - we'd have call to autoload and > subsequent disk access, maybe more than one if we have include > path. Performance of it would be awful. > 2. All libraries having autoloaders would have to rewrite them to > support the new mode. > > I would propose different solution. When we have unresolved > unqualified name, we do the following: > 1. Check if we already know such class in namespace at compile- > time. If so, it's resolved. > 2. If not, will be resolved at run-time. > 3. At run-time, check if we know such class in namespace now. If > yes, it's resolved. > 4. If not, check if we know internal class with such name. If yes, > it's resolved to internal class. > 5. If not, try to autoload this class. If autoloading fails, it's > the undefined class error. > > This rule is a bit more complex, but allows to resolve common cases > without extra filesystem accesses and allows to keep autoloader > without modification. > > Comments? > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >