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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to