Andi,
I tend to agree with Bob on this one. Class vs. instance is an important distinction and, although the syntactic sugar of being able to reference a static member directly through an object and a scope resolution operator could be nice, I don't think the semantics are necessarily 100% clear. As with my other positions, I'm probably rather pedantic, but I believe that scope resolution operator should be used for ``compile-time'' notions, rather than ``runtime'' notions like referencing the class of an object, rather than inferring it from an instance. I would say that existing and additional features of the object model provide for this technique in a manner more consistent with other object systems.
Specifically, the class, or base class of an object should be known if a user is to reference static members. In cases where the exact subclass is required, get_class() provides a suitable technique. The notation of $var::member should be reserved for expansion of a string in $var, naming a known class. I believe the class type hints also solidify the design patterns and relieve some possibility of being handed an object that may not conform to a given interface (exposing the required static members), limiting the application of this patch.
All in all, although it would be handy, I'm not sure that deviation from other C-style languages in allowing scope resolution on instance variables really adds very much benefit beyond syntactic sugar and I fear that it may cause some undue confusion depending on variable naming (``Is that an object whose class is being referenced at runtime or a string that is being expanded and considered a class name?'').
Thanks, -Noah
Andi Gutmans wrote:
>> Any other opinions? >> >> At 11:34 PM 10/4/2004 -0700, Robert Silva wrote: >> > >>>> While this patch does add convienence at times, I don't think the >>>> benefit is >>>> great enough to blur the lines between class and object >>>> properties/methods. >>>> As was stated in the "goto" discussions, the language designers have >>>> somewhat of a responsibility to promote proper coding practices (which >>>> should also include standards to some extent). >>>> >>>> Bob Silva
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php