Hi,
I did consider that as an alternate option.

function overload_register($op, $lhtype, $rhtype, $callback);

overload_type(ZEND_ADD, 'Complex', 'any', 'Complex::add');

This would get pretty expensive in terms of large lookup tables though, so I'm 
hesitant there.
This is much better, IMO, as the syntax can be extended to every type hints (including union types in the future). It also allows to overload operators on scalar types (operation on arrays for instance). Magic methods just don't fit there.

But I'm not sure we should overload at the opcode level, as the userspace method should receive different codes for '+=' and '+'. Anyway, supporting scalar types, union types, and 'any' without loosing too much performance is far from obvious.

Regards

François


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

Reply via email to