On Thu, Jan 30, 2020 at 10:22 PM firstname.lastname@example.org> wrote:
> > 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.
Looks much better! If you submit a pull request, I can leave some more
> 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.
Don't really see a reason not to support it. We do overload the bitwise not
operator for GMP objects, and it would be equally applicable to other
"integer" style objects.
If you would like to start an RFC on this topic, please sign up for a wiki
account (https://wiki.php.net/rfc/howto) and send me your username.