Re: RE:Class::? - accessing data, no success...

From: Date: Thu, 06 Jul 2000 04:57:43 +0000
Subject: Re: RE:Class::? - accessing data, no success...
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-23658@lists.php.net to get a copy of this message
I don't think what you're talking about is so ambiguous. We actually planned it this way. The logic behind it is, if you call a function which is supposed to be "static" then you won't be using $this inside of it and it will work without problems from the global scope. If you call a function which uses $this from the outside then it will be called but you won't have a $this defined (a programming error of the PHP coder). I think it's not that ambiguous or bad the way it is now. Andi At 12:54 PM 7/4/00 +0200, waldschrott wrote:
w>> The most important thing is retrieving the data, if one could change the w>> initial class declaration with $class::var=$x; - nice, but I think w>> Zeev&Andi won?t like that ;) - and if you decide implementing this
SM> That doesn't work this way. $class::var should be some variable, which can SM> be used in any expression. The question is - what variable is it? Where it SM> comes from? The :: is implemented somewhat ambiguous, I *do not prefer* using the :: syntax for static calls, we´d introduce grave ambiguities then (thouroughly explained at the bottom). The :: syntax is already in use to access overriden methods, but the current implementation allows calling :: from outside, too that´s a bit ambiguous, let me explain why: (A)If :: is called from within objects, you can use it to access override methods. Data members that have been created in the overriden class can be accessed, but only via the methods (not using ::). (1) :: could be extended to enable accessing overriden data members from within objects too: not so important, don´t know if it´s possible, just an idea. (B) If :: is called from outside, you can access a class´s methods directly, but you can´t access it´s data members, because they have not been created, the class has not been instanciated. (2) I´d prefer that accessing methods other than the overriden ones via :: should *not* be possible, instead to do this there should something newly be introduced to make static calls to methods of non instanciated classes (and by doing this static calls to data members should be made possible too). In the following example :: acts to access an overriden method in (1) and then it acts like a static call in (2), but has (as said) no access to it´s datamembers. <?php class a { var $test='foo'; function a () { print $this->test; } } class b extends a { function a () { a::a(); }} print "1)"; new b; print "2)"; a::a(); ?> *If* we allow static calls then, we should *not* use ::, then we´d introduce further ambguities, then the above example would be expected to EITHER a) act like above for (1) and error for (2) [override only] b) in both cases: act like above for (1) but actually performing a static call, that should use the var $test from a, even if it has been overwritten in b [static calls only] I´d say we should introduce a new operator for static calls *if* introduced, otherwise the side effects would not be comprehensive users, I think. regards --
o----------0-¬---------O-·---¬----o---®-----o o    O   °       .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0  O °     ¤  °        ·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © ° . ·
| psychedelic experience |  gott@kiffen.de  | O   ° o           °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·
--- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.dev (#23658) next »