Luke Palmer wrote:
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

Or even $u *= $v :-)

Yes, I can see that would be a problem. Care obviously required with the types of operator methods as in other languages.

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.

I didn't think we would be, as it would be hideously difficult to pick the right method to dispatch to, but I thought I'd check.


Thanks

Matthew



Reply via email to