May I suggest using foo::__CLASS__ instead of foo::class ? It's longer,
but closer to what already exists for this semantic (class name as
string), don't you think ?


As Marco suggested, I think using __CLASS__ would be confusing to some. __CLASS__ generally means, "where you see this, replace it with the class you are in right now".

I generally don't like to draw comparisons too closely to Java and .NET, but Java has this, they call it a "class literal", which works the same way as described in my new feature:


http://stackoverflow.com/questions/2160788/what-is-a-class-literal-in-java

In .net, if a type is a SystemType.Type object (which I think are all types), you can simply call a function on it to get the name:

  http://msdn.microsoft.com/en-us/library/9f49ew66.aspx

In addition, I am unsure if there would be any BC issues with your proposed syntax. I do know with mine (::class) does not pose any BC issues since the class keyword was limited to declaring a class only. At least, the tests prove this, and I can't find any other usages of T_CLASS in the parser.

Personnaly, I would say that an RFC would be good for historical
reference and documentation.

I think you're right, I'll do this today.

-ralph

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

Reply via email to