On Friday, 20 September 2024 at 15:09, Christoph M. Becker <cmbecke...@gmx.de> wrote:
> On 20.09.2024 at 15:00, Gina P. Banyard wrote: > > > This leads to a rather insane situation where the engine does not assume + > > is always commutative but does so for *, something which makes no sense as > > multiplication or product operations are (in the grand scheme of > > mathematics) rarely commutative. > > > Gosh, I had completely forgotten about ZEND_TRY_BINARY_OBJECT_OPERATION. > So I withdraw my statement about the only reasonable way to implement > operator overloading in PHP[1], and state that there is no reasonable > way to implement operator overloading in PHP at all (excluding > comparison and equality operations), since apparently, we cannot even > get the only two internal bundled classes to properly handle this. > Cf. https://3v4l.org/gksqI/rfc#vgit.master and > > https://3v4l.org/o5Uhh/rfc#vgit.master. > > > [1] https://externals.io/message/125550#125621 The issue here is that GMP does not return FAILURE when it does not support an operand, but instead throws an exception, which blocks any polymorphic handling. Being currently knees deep in the implementation of GMP it does some questionable stuff and should be refactored. However, the fact that if only one operand is an object and returns FAILURE and the binary operation can still succeed is a bit of an issue which needs to be address regardless IMHO. Best regards, Gina P. Banyard