Re: RFC Operator Overloading in Userspace
| From: | Mark Baker | Date: | Sun, 03 Jan 2016 12:50:31 +0000 |
| Subject: | Re: RFC Operator Overloading in Userspace | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89978@lists.php.net to get a copy of this message | ||
On 03/01/2016 02:14, Sara Golemon wrote:
Patricio Tarantino has asked me to help him propose Operator Overloading in PHP 7.1 (based in part on my operator extension in PECL). I think we can expose this to usespace as magic methods with very little overhead (the runtime check and dispatch is already there, after all). https://wiki.php.net/rfc/operator-overloading It's something I'd love to see, and would be particularly useful for my Complex Number and Matrix libraries, but (as Bishop says) the large list of magic methods does feel excessive, and a single dispatcher method feels simpler.But how then would it be possible to overload several operators? If the __overload() dispatcher method has to implement a switch on the value of the operator argument, and implement error handling for invalid or non-implemented operators, it's pushing a lot of complexity into that magic method -- Mark Baker _________ |. \ \-3 |_J_/ PHP | || | __ | || |m| |m| I LOVE PHP