Hi,

Not wanting to discuss the pros and cons of operator overloading in PHP a
few notes about the implementation:

Stanislav Malyshev wrote:
> 2. The referenced patch raises doubts - why it allows to override / but
> not %, for example? What with all other operators? Why add would work as

I've written the patch mainly for learning about PHP and the Zend Engine as
a proof-of-concept and not as a thing I would like to propose so I was
satisfied when it was running. By showing it to a few people I got some
feedback about the way I've implemented it and learned how to do it better.
Most of this input ended at my brain not in the patch so it's far from
good, I still stress that I'm no C coder ;-)
So all what's (not) there needs to be seen from that position. For being
committed it would need some work.

> $foo + 1, but 1 + $foo won't? Will + be non-commutative operation from now

In case of operator overloading this would become true - not for simple
types - when leaving the field of simple numbers an "addition operation"
isn't allways communitative. Think on "adding" two strings - you would
expect different results from "foo"+"bar" and "bar"+"foo". (Yes, I know
that PHP has the concat operator . so this is just an example)

> on? What with assign-ops - it would leak memory in this case?

As said it's in proof-of-concept state. I last looked over it during the
conference in Frankfurt and afair at least --enable-debug didn't report a
leak ;-)

Enough (if not even too much) for the moment,
johannes

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

Reply via email to