Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43075 invoked from network); 4 Nov 2008 16:15:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2008 16:15:40 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 74.125.44.28 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 74.125.44.28 yx-out-2324.google.com Received: from [74.125.44.28] ([74.125.44.28:53443] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/16-15458-B2570194 for ; Tue, 04 Nov 2008 11:15:40 -0500 Received: by yx-out-2324.google.com with SMTP id 3so1182100yxj.83 for ; Tue, 04 Nov 2008 08:15:37 -0800 (PST) Received: by 10.64.201.16 with SMTP id y16mr2334989qbf.67.1225815336562; Tue, 04 Nov 2008 08:15:36 -0800 (PST) Received: from ?192.168.0.106? ([76.84.4.101]) by mx.google.com with ESMTPS id s30sm20259850qbs.8.2008.11.04.08.15.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 Nov 2008 08:15:35 -0800 (PST) Message-ID: <49107527.7060604@chiaraquartet.net> Date: Tue, 04 Nov 2008 10:15:35 -0600 User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: Christian Schneider CC: Lukas Kahwe Smith , PHP Development References: <49048EC1.9060908@chiaraquartet.net> <49061E01.8060503@zend.com> <11c607a60810271344i1a8cf53fl149447ad2f687f99@mail.gmail.com> <490628DB.9060209@zend.com> <11c607a60810271422l68949427pe31786275b0b152c@mail.gmail.com> <08747094-6B50-4A0D-9057-DFD12108B6C6@caedmon.net> <94CCB864-179A-48DA-A89A-3859796A9257@pooteeweet.org> <49063A1D.7070804@zend.com> <4906405F.7090205@zend.com> <490747B2.2010201@zend.com> <4D9A8597-EFE6-418A-B7F6-EAD9ED2361A5@pooteeweet.org> <7FA6946B-57B9-4BC0-B2F1-AFD47572F363@pooteeweet.org> <491071EC.7020501@cschneid.com> In-Reply-To: <491071EC.7020501@cschneid.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] namespace separator and whining From: greg@chiaraquartet.net (Gregory Beaver) Christian Schneider wrote: > Lukas Kahwe Smith wrote: >> one could also do >> 1) ns >> 2) global >> 3) autoload > > I'm in favour of this (if it avoids performance problems) as I don't see > a problem with giving global priority over autoload. Hi, This is the current name resolution. The problem is that: will instantiate foo::Exception only if the class already exists, but will instantiate Exception otherwise. This defeats autoload's purpose for existing. We've been over this before. It's dangerous. There is one essential difference between classes and functions/constants: autoload. The only time the question of load order and fallback becomes and issue is when code is not explicitly loaded. In other words, a developer who is relying upon an external function will do this at some point before calling the function: In other words, PHP expects you to actually load the source of functions or constants you're going to be using in advance of using it. This, I believe, is a reasonable expectation. Classes, however, do *not* share this same expectation, because autoload's explicit purpose is to allow using classes *before* their source has been loaded. In other words, it is perfectly all right to have a different name resolution for classes than we have for functions and constants because of this different expectation. It is dangerous to fallback for classes prior to autoload, but it is not at all dangerous for functions/constants because the expectation is different. For this reason, the only resolution that we should be considering is: classes: 1) try ns::class 2) autoload ns::class 3) fail functions/constants: 1) try ns::function/ns::const 2) try internal function/const 3) fail. Note that I say "try internal" because the only purpose behind allowing this is to make it easier to use PHP's built-in functionality. Any userspace stuff should be specifically \prefixed or imported via use. And (yes) we need import for functions. Greg P.S. my mail server has been down for almost a week, apologies to anyone who is wondering why I haven't replied to your message, I probably didn't get it.