It's basically Hindley-Milner.

jmh530 john.michael.hall at gmail.com
Fri Mar 24 13:31:55 UTC 2023


On Friday, 24 March 2023 at 12:29:02 UTC, kdevel wrote:
> [snip]
>
> Thanks for explaining what goes on under the hood. I would like 
> to branch to something entirely different, namely the original 
> code Elfstone drafted in the first post:
>
> ```
> struct Matrix(S, size_t M, size_t N)
> {
> }
>
> alias Vec3(S) = Matrix!(S, 3, 1);
> ```
>
> What is conceptually wrong with this code? Can't we read 
> everywhere [1] that matrices with only one column ‘are’ 
> (column) vectors?
>
> [snip]

There's a lot that can get hidden in `Matrix` since this uses 
template parameters to define the dimensions of a `Matrix` (like 
a static array). For instance, it could specialize code for the 
case where `N=1` so that it really behaves like a vector. It 
could have a special dot product function that behaves 
differently in this case vs. normal matrix multiplication (and 
could call that dot product code when doing a matrix 
multiplication instead, BLAS has ddot and dgemm and D is powerful 
enough to call different ones at compile time).


More information about the Digitalmars-d mailing list