Matthew Walton writes:
> However, if I alter my operator overload to be
>
> multi sub *infix:Â+Â (EvilNumber $lhs, EvilNumber $rhs) is deep { ... }
>
> I get *infix:Â+=Â defined as { $lhs = $lhs + $rhs; } for free. Is that
> right?
Yep.
> Also, would things blow up if I specified the return types for operator
> overloads, such as
>
> multi sub *infix:Â+Â (EvilNumber $lhs, EvilNumber $rhs) returns
> EvilNumber is deep { ... }
In that case I don't see why it would blow up. If you said, say:
multi sub *infix:Â*Â (Vector $lhs, Vector $rhs)
returns Num is deep
{ ... }
Then you might get into trouble if you did
$u += $v
> Would that work, would it behave strangely and what would it do to the
> definition of infix:Â+=Â which would be based on it? Is it even
> necessary? Does it give me anything? And can I overload based on return
> types?
I can't be sure, but I don't think that we're doing MMD on return types.
The most compelling reason for that is because you can get yourself into
paradoxes that way.
Luke