Re: [Operators overloading] PHP 5.1

From: Date: Thu, 03 Feb 2005 17:12:44 +0000
Subject: Re: [Operators overloading] PHP 5.1
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-14574@lists.php.net to get a copy of this message
> On Thu, 3 Feb 2005 11:47:13 +0100 (CET) > derick@php.net (Derick Rethans) wrote: > > > On Thu, 3 Feb 2005, Sebastian Bergmann wrote: > > > > > Derick Rethans wrote: > > > > Use C++/Java if you want this. > > > > > > Java does not support operator overloading. > > > > So, that means PHP shouldn't get it either, right? ;-) > > As I already asked in the past, I'm in favour to have them for > intern usage only (understand used by extension). Internal in what way? And why? > As we already for > propoerties read or write. For those who do not know, you have no > way to know that you in a ++, -- call. At least for ++,-- and > friends. I'm not sure I understood the above, but if I understood it right, why would that be? class SomeClass { function operator++() // #1 { return ++$this->value; } function operator($dummy) // #2 *** { return $value++; } var $value; } $object=new SomeClass(); ++$object; // Calls #1 $object++; // Calls # 2 (***) This is how it's done in C++ (actually, a dummy int parameter), which is a bit of a hack, to be able to specify both the pre- and post-increment/decrement operators. #2 (and postfix "--") is the "odd" one, since they are the only postfix operators among the operators. Regards, Terje

« previous php.internals (#14574) next »