Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41249 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21533 invoked from network); 17 Oct 2008 21:07:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2008 21:07:30 -0000 X-Host-Fingerprint: 64.8.134.189 unknown Received: from [64.8.134.189] ([64.8.134.189:12919] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/85-19022-09EF8F84 for ; Fri, 17 Oct 2008 17:07:29 -0400 To: internals@lists.php.net,=?UTF-8?B?UGF3ZcWCIFN0cmFkb21za2k=?= Message-ID: <48F8FE8D.5000600@gmail.com> Date: Fri, 17 Oct 2008 16:07:25 -0500 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 CC: Greg Beaver References: <48F653FF.5010106@chiaraquartet.net> <63.BA.57950.BB2A8F84@pb1.pair.com> <200810172220.23260.pstradomski@gmail.com> In-Reply-To: <200810172220.23260.pstradomski@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 64.8.134.189 Subject: Re: [PHP-DEV] Re: my last attempt at sanity with namespaces From: rpanning@gmail.com (Ryan Panning) Paweł Stradomski wrote: > W liście Ryan Panning z dnia piątek 17 października 2008: >> Request Autoload Gets Type >> ----------------------------------------------- >> A::B:>C A::B:>C Class >> A::B:>func() A::B Namespace >> A::B:>C::CONST A::B:>C Class >> A::B::C:>D::method() A::B::C:>D Class >> A::B::C::D:>CONST A::B::C::D Namespace > > I'm just a mere user, but if we go for other namespace separator (be it ::: > or :> or anything else), then I'd rather see it used both between namespace > and class/function/constant name *and* between namespace parts. To be clear - > for the examples above I'd rather have them written as: > > A:>B:>C > A:>B:>func() > A:>B:>C::CONST > A:>B:>C:>D::method() > > or A:::B:::C, A:::B:::func, A:::B:::C::CONST. > > That way :: is just operator for static class access (static methods and > properties), while :> or ::: is just namespace access operator, so we can > always assume that anything on the left side of ::: or :> is a namespace. In > Ryan's version :: is sometimes static class access operator, sometimes > namespace segment separator, depending on position. > That would be #1 in the options. I thought about that but then the autoloader would get exactly the same input as it does now, just with a different separator. To truly help the user make an autoloader that knows what it should be loading you must separate class from namespace request. The parser should know what to string to send to the autoloader by: Namespace: Element after the element separator is a CONSTANT or function(). Ex: $func = A::B::C:>func(); $const = A::B::C:>CONST; Class: Element after the element separator is a class CONSTANT or static method or it is a "new" request. Basically if there is :: after the element separator. Ex: $method = A::B:>C::method(); $cconst = A::B:>C::CONST; Just to note, the below could be viewed as a namespace request. However, because it's a "new"/construct request we know that it's a class. $obj = new A::B:>C; $obj = new A::B:>C(); Note, this option has lost in the voting already. Although I think this issue will come up at a later point anyway. Also, in Greg's wiki, for option #2, I don't see how it's possible to Get::Any::Deeper:>Than::THIS = Class Constant It::Just::Does:>Not::Seem:>POSSIBLE = Namespace Constant of? This::Could::Vary:>Well::$Be::POSSIBLE = Class Const of Static Class Var