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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to