Re: Re: Static weirdness..

From: Date: Sun, 22 Feb 2004 05:30:38 +0000
Subject: Re: Re: Static weirdness..
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-8043@lists.php.net to get a copy of this message
If I'm not mistaken, Java does not allow calls to static methods via object instances. It simply doesn't make sense to couple the unecessary object instance into a method call in which it has absolutely no bearing. If the object has nothing to do with the operation, then there's no point for it to be in the syntax. I am completely in favor of a $stringName::staticMethod(); type call if this hasn't already been done. Consider the following piece of code: class Foo{ function register(){ .... } } $instance = new Foo(); $instance->(); Quoting Art Hundiak <zhundiak@comcast.net>: > On Friday 20 February 2004 20:23, Herr Witten wrote: > > Well, calling a static method from an instance breaks down the logic. > > If it is static, then the instance has absolutely no bearing when > > calling it. Therefore, it logically makes sense to call only from the > > class name. > > > > Moreover, making a distinction between the method calling syntax begins > > to make the distinction between class objects and instance objects. I > > have a class which deals directly with classes and their static methods > > as if they are objects. This is a powerful notion that still needs more > > support in the Zend engine. > > > > The call for static method should be: > > > > ClassName->method(); > > > > Herr Witten > > > > > C++ allows $a->bar() when bar() is a static method (yes, it is called > > > in a static context there too). > > > > > > IMO, there should be no error, warning or notice here. > > Regardless of the final implementation, I think access to static methods and > > static class variables should be consistent. Currently, you cannot access a > > class variable via an object instance. > > And for what it's worth, I see no reason why static methods cannot be called > > from objects. Follow Java/C++ in this case. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.internals (#8043) next »