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

This is only part of a thread. view whole thread
  108341
February 1, 2020 09:22 nikita.ppv@gmail.com (Nikita Popov)
On Thu, Jan 30, 2020 at 10:22 PM boehmer@gmx.de> 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 detailed comments.
> 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. Nikita
  108342
February 1, 2020 10:36 jan.h.boehmer@gmx.de
On Sat, Feb 1, 2020 10:22 AM ppv@gmail.com> wrote:
> Looks much better! If you submit a pull request, I can leave some more detailed comments.
Okay, I will submit a pull request with my changes.
> 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.
My Wiki account name is jbtronics. Thank you, Jan Böhmer