Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25545 invoked from network); 4 Nov 2008 23:52:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2008 23:52:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:43895] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/0D-15458-230E0194 for ; Tue, 04 Nov 2008 18:52:19 -0500 Received: from MBOERGER-ZRH.corp.google.com (238-78.107-92.cust.bluewin.ch [92.107.78.238]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id EA3B111F705; Wed, 5 Nov 2008 00:52:14 +0100 (CET) Date: Wed, 5 Nov 2008 00:49:25 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <885621138.20081105004925@marcus-boerger.de> To: Lukas Kahwe Smith CC: Marcus Boerger , Gregory Beaver , Christian Schneider , PHP Development In-Reply-To: <6246E5E0-BD11-48E2-B32B-DA7F82E605E2@pooteeweet.org> 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> <49107527.7060604@chiaraquartet.net> <1652368155.20081105001225@marcus-boerger.de> <6246E5E0-BD11-48E2-B32B-DA7F82E605E2@pooteeweet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] namespace separator and whining From: helly@php.net (Marcus Boerger) Hello Lukas, Wednesday, November 5, 2008, 12:32:19 AM, you wrote: > On 05.11.2008, at 00:12, Marcus Boerger wrote: >>> classes: >>> 1) try ns::class >>> 2) autoload ns::class >>> 3) fail >> >> Since we can stack autoload we could provide a c-level autoload >> function >> that does the default lookup. >> >> function global_autoload($name) { >> if (($p = strrpos($name, '\\')) !== false) { >> $name = substr($name, $p); >> if (__NAMESPACE__ == substr($name, 0, $p -1) && class_exists("\\ >> $name")) { >> use "\\$name"; // if we find a way to do this at C-levle >> } >> } >> } > just to make sure i understand this correctly .. you are suggesting > here that we make it somehow possible in __autoload() to fallback to > the global namespace. so that if someone wants the fallback to global > namespace behavior for classes, he could get this by calling this > standard autoload function (or rather by using the spl autoload stack > - noting that spl may not be disabled anymore as of PHP 5.3). yes > more specifically you want to enable use statements inside autoload. i and yes > presume that use statement would only be in effect for this single > name resolution? and yes > as in the use statement would not have an affect on > subsequent triggering of autoload, even when originating from the same > file? and yes or in other words give the user the ability to specify when he wants the fallback to global and not doing a fallback to global per default. That way we get an efficient lookup witout a double retry: 1) local 2) autoload 3) fail while the user can stack above in first: 1) local 2.1) autoload as above == global 2.n) autoload 3) fail and also stack at the end: 1) local 2.n) autoload 2.X) autoload as above == global 3) fail Best regards, Marcus