Re: Implementation (simple!) operator overloading
| From: | Andi Gutmans | Date: | Mon, 10 Jul 2000 04:15:30 +0000 |
| Subject: | Re: Implementation (simple!) operator overloading | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23988@lists.php.net to get a copy of this message | ||
You deserve an A+ for effort :)
However, I really don't want to see operator overloading in PHP. One of the things I like in Java is that they removed this kind of bloat as opposed to C++.
I prefer interfaces & methods and think operator overloading code is just too unreadable.
Andi
At 01:21 AM 7/10/00 +0200, Mathieu Kooiman (ggInternet) wrote:
Hiya, I implemented simple operator overloading for Zend/PHP Allowing constructions like this:--- Andi Gutmans <andi@zend.com> http://www.zend.com/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/ -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net