Martin Nowak is officially MIA

Timon Gehr timon.gehr at gmx.ch
Sat Mar 29 23:07:12 UTC 2025


On 3/29/25 01:17, Dennis wrote:
> On Thursday, 27 March 2025 at 22:04:53 UTC, sfp wrote:
>> A way around this problem that does work but isn't particularly 
>> satisfying is to kiss operator overloading goodbye. Just use `mul` for 
>> matrix multiplication. There's a good chance this is what I'll end up 
>> having to do.
> 
> As a workaround, have you considered making operator overload members 
> forward to one generic function?
> 
> ```
> auto opBinary(string op : "*", T)(T other) => mul(this, other);
> ```
> 
> That's O(n) boilerplate, as opposed to O(n^2) opBinary implementations.

Well, your type may be compatible with some built-in types as well, so 
you also need opBinaryRight. And then when you have multiple types that 
use this strategy, you have to break the symmetry somehow to avoid 
ambiguity errors. Furthermore, now the type's module has to import every 
operator implementation you ever want to use.

This all seems a bit much to ask for the convenience of using the 
standard operator notation for your calls to mathematical functions.


More information about the Digitalmars-d mailing list