Re: PHP 5.1

From: Date: Thu, 03 Feb 2005 10:42:29 +0000
Subject: Re: PHP 5.1
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-14563@lists.php.net to get a copy of this message
Derick Rethans wrote:
On Thu, 3 Feb 2005, Sebastian Bergmann wrote:
Derick Rethans wrote:
This adds operator overloading to user classes?
Yes, have a look at Johannes' Complex example [1].
Okay, mega Yuck then. Although it looks cool, I consider it as a bad practise. It confuses the hell out of people that they can add two objects. Use C++/Java if you want this...
I couldn't agree more. I like PHP not because it is the most compact or flexible of all languages but because the syntax is quite simple. Try explaining someone who just learned PHP and doesn't know your code where to find the implementation of $c = $a + $b; as opposed to $c= $a->add($b); or $c = Complex::add($a, $b); Another little thought how confusion can easily happen with operator overloading: $b = $a + 42; works but $b = 42 + $a; doesn't, i.e. the overloaded addition isn't commutative. Just my 2 Rappen, - Chris

« previous php.internals (#14563) next »