Implementation (simple!) operator overloading

From: Date: Sun, 09 Jul 2000 23:21:28 +0000
Subject: Implementation (simple!) operator overloading
Groups: php.dev 
Request: Send a blank email to php-dev+get-23975@lists.php.net to get a copy of this message
Hiya, I implemented simple operator overloading for Zend/PHP Allowing constructions like this: define ("USE_INT", 1); class test { var $blah; function overload- do_minus_overload( $subject ) { if (!is_int($subject)) return USE_INT; return substr($this->blah, 0, (strlen($this->blah) - $subject)); } } $muh = new test(); $muh->blah = "This is a long string and we're gonna chop off 10 characters"; print "Current muh::blah = {$muh->blah}\n"; printf("Muh - 10 = %s\n", ($var=$muh - 10) == USE_INT ? "Error!" : $var); Mostly as proof to myself I could do it, I wonder how much interest there is for it.. If there is how do I get it to you ppl, since it has changes in multiple files:)) (all in Zend code btw) For now it only implements overloading for '-' and '+' currently working on a way to get -= and += to work.. ( Btw, I figure this would make me the youngest here .. being 17 :) Not sure, didn't follow complete thread ) Mathieu Kooiman - <caps@gge.nl> GG-Internet Webdesign - http://www.gginter.net/

« previous php.dev (#23975) next »