On 03.01.22 17:12, Larry Garfield wrote:
Also, people keep talking about edge cases. In my experience, "are
these two objects equal" (for some object-specific definition of
equal) is very much *not* an edge case. I may have less use for
overloading % as I don't use advanced math that much, but I compare
things all the frickin' time and that would be incredibly useful day
to day.

Maybe some of the resistance against this RFC is the (understandable)
focus on mathematical (or mathematical-adjacent) operations, making it
seem that the "real" use-cases are narrow, whereas comparing objects
could make quite a bit of code more readable, like comparing addresses,
prices, availability or location/position. Having regular methods for
operators is possible, but when used a lot the readability does start to
suffer.

The difficulty in arguing for operator overloading might be that the use
cases are specific to a codebase and mainly become apparent once it is
available (currently you just work around it). I do think it is a
reasonable tool to make some code vastly more readable, and I don't see
"novices" using operators a lot - PHP has many simpler features to abuse
that can make code absolutely terrible.

The RFC is really well thought out and reasoned, by the way - great work
Jordan!

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to