On Sat, Mar 28, 2020 at 10:19 PM Andrea Faulds <a...@ajf.me> wrote:

> Hi everyone,
>
> Johannes Schlüter wrote:
> >
> > If we use two methods as well it is a saner design. I won't like it, but
> lot better than the current one.
>
> Just want to +1 this. Two methods, neither of which are static, seems
> like a cleaner approach to me. I maybe like this better than my
> suggested boolean argument (it certainly looks nicer).
>
> Consider what happens in the current proposal if a class, intentionally
> or otherwise, only supports being on one side of an operator… it will
> produce the same error message as if it didn't support the overload at
> all :(


Could you please expand on what the advantage of using two instance methods
over one static method is? As far as I can tell, Python uses this design
because they don't really have static methods (let's gloss over the
@staticmethod decorator here), so it's basically their only choice.

I don't buy your error message argument. Assuming
https://wiki.php.net/rfc/arithmetic_operator_type_checks passes, the error
you're going to get is something like "Unsupported operand types: int /
Vector", which seems reasonable to me, and leaves potential support for
"Vector / int" open.

The presence of only one of the two method could not be used for the error
message anyway, because presence of the method does not imply actual
support of the type combination, and we certainly wouldn't want to do a
call for the reverse order to adjust the error message.

Regards,
Nikita

Reply via email to