>From: "Greg Beaver" <[EMAIL PROTECTED]>

> Terje Slettebø wrote:
> > 1) $result=$c1.multiply($c2).divide($c1.add($c2));
> >
> > 2) $result=($c1 * $c2) / ($c1 + $c2);
> >
> > They sure aren't to me. Moreover, they are not the same: operator
> > overloading enable you to use infix notation, whereas functions use
prefix,
> > only.
>
> Um, you're wrong.  Infix is quite easy to do using (static or
> non-static) functions:
>
> 3) $result = Complex::divide(Complex::multiply($c1, $c2),
Complex::add($c1, $c2));

Let me rewrite your expression as an abstract expression:

result = op(op(c1, c2), op(c1, c2))

Here, "op" is the function name ("add", etc.). As you can see, your
expression is still one using prefix operators ("op arg1 arg2"), rather than
infix ("arg1 op arg2"). I'm afraid your correction is incorrect.

Your example is the same as 1), above, using static functions.

Regards,

Terje

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

Reply via email to