Should we add `a * b` for vectors?
jmh530
john.michael.hall at gmail.com
Fri Oct 6 21:10:45 UTC 2017
On Friday, 6 October 2017 at 20:36:47 UTC, Jonathan M Davis wrote:
>
> It forces them to actually be designed with the type and be
> easily located with the type. Would you want a programmer to be
> able to go and implement opBinary!"+" for strings? I sure
> wouldn't. And I don't want anyone doing that for user-defined
> types that they didn't define either.
>
Hmm, you could think of it like the current default is that you
cannot do outer operator overloading. We have @disable this();
for disabling default construction. What about something like
@outer T opBinary(string op)(T)
if(op == "+")
which means that it allows opBinary to be defined outside the
struct/class. The default would be that it's not allowed. And it
would give a hint to somebody that they would need to look for
that method elsewhere?
More information about the Digitalmars-d
mailing list