operator overloading outside the type
Derek Fawcus
dfawcus+dlang at employees.org
Sun Mar 30 09:31:32 UTC 2025
On Sunday, 30 March 2025 at 05:30:42 UTC, sfp wrote:
>
> I want to be able to define standard mathematical operators for
> standard mathematical entities (numbers, matrices, polynomials,
> etc). My code is nontrivial because of the domain I work in,
> not because of the code itself.
I suspect it would be possible to use CTFE over strings in order
to have an evaluate function return a user defined type (say a
matrix), while using normal infix maths operators.
So one would end up with something like:
```
matrix a, b, c;
a = eval!matrix( "b * c" );
```
So that the whole thing would be a compile time transformation.
To what extent one could then do type checking of the expression
would be an open question.
More information about the Digitalmars-d
mailing list