RE: [PHP-DEV] Operator overloading for userspace objects

From: Date: Thu, 30 Jan 2020 21:22:42 +0000
Subject: RE: [PHP-DEV] Operator overloading for userspace objects
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-108333@lists.php.net to get a copy of this message
> Unfortunately, this implementation goes in the wrong direction: PHP already has full internal > support for operator overloading through the do_operation object handler. Operator overloading > should be exposed to userland through that handler as well. I have made another implementation (https://github.com/jbtronics/php-src/tree/operator_overloading) which provides an standard handler for do_operation, which calls the functions in user space. I also removed the __compare magic function from my implementation, so this can be handled separately. Another thing: What are your opinions on overload the bitwise not operator (~)? My implementations offers every other bitwise operator and this one would complete the set of bitwise operators. On the other hand unary operators does not have much use for objects and maybe encourage people using them as "shortcut" for calling things on the object, where an explicit method call would make the intend function more clear. Regards, Jan

« previous php.internals (#108333) next »