Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38777 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82320 invoked from network); 5 Jul 2008 16:49:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jul 2008 16:49:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=cellog@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cellog@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 208.83.222.18 as permitted sender) X-PHP-List-Original-Sender: cellog@php.net X-Host-Fingerprint: 208.83.222.18 unknown Linux 2.6 Received: from [208.83.222.18] ([208.83.222.18:54270] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/7A-10299-406AF684 for ; Sat, 05 Jul 2008 12:49:09 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 53CF1C1318F; Sat, 5 Jul 2008 09:49:02 -0700 (MST) Received: from [192.168.1.120] (static-64-115-191-41.isp.broadviewnet.net [64.115.191.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 97DC3C13182; Sat, 5 Jul 2008 09:48:59 -0700 (MST) Message-ID: <486FA5FB.1000300@php.net> Date: Sat, 05 Jul 2008 12:48:59 -0400 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Lukas Kahwe Smith CC: PHP Developers Mailing List , Dmitry Stogov , stanislav Malyshev References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: towards a 5.3 release From: cellog@php.net (Greg Beaver) Lukas Kahwe Smith wrote: > Aloha, > > Since Johannes has been stumped (and therefore not as visible as he > would have hoped) with work and 5.3 CVS is already filled brim with > awesome new features, I have been approached by several people wondering > how we can speed up the process. I have always said I am available to > play the secretary to the RM, but in order to ensure that developers > have a greater chance of having an RM to talk to, Johannes agreed to > move me to co-RM status. glad to hear it! > 1) namespaces > Here we need to make sure that the current state is now in a coherent > state. I think Derick still has some issues [3] with the recent change > by Greg [4], but even his criticism did not sound all to loud. So I > think we are in a good state here? My recent changes aside, there are still some fubar issues with name resolution, and there has been some offlist discussion of ways to fix this that have not led to concrete onlist proposals yet. For those who don't know what I'm talking about, the question is how to resolve an unqualified classname inside a namespace. i.e. this code: a.php: Currently, the above code would throw ::Exception, because if a namespaced class does not exist, internal classes are checked before autoloading for performance reasons. However, if we execute this code instead: b.php: then a.php would throw Foo::Exception. In other words, depending on file inclusion order, classnames can change with current PHP accepted practices. The solution to this is to use each namespaced class explicitly: a2.php: However, all it takes is one forgotten "use" statement, and a very subtle bug could be introduced later. Taking a step back, let's examine why autoload is not called before checking internal classes - it is for performance reasons. However, this performance enhancement causes unpredictable behavior *by default* without explicit action. There is a simple solution, however. If one changes the name resolution to this pseudo-code: 1) check Foo::Exception for existence 2) if not found, try to autoload Foo::Exception 3) if not found, check for ::Exception existence, userspace *or* internal (addition of userspace check also fixes other problems raised on-list) 4) if not found, fail. This fixes the logic problem, and re-introduces the performance slowdown for internal classes. FORTUNATELY there is a simple solution to this, which is to "use" all global classes: The above code works exactly the same as: and short-circuits the name resolution to: 1) check ::ArrayIterator for existence 2) if not found, fail. To summarize, we should scrap the "performance enhancement" that introduces the potential for subtle and dangerous logic errors in name resolution because it is still possible to achieve that performance enhancement through one-time "use" of internal classnames. With these changes, namespace classname resolution will be 100% deterministic regardless of file load order, it will still be possible to override internal classnames with userspace classes, and for the ultra-performance hungry, it is still easy to achieve faster classname resolution for internal classes. Win-win. Greg