I’m new to Odin, and am liking it quite a bit. Recently, however I spent over an hour debugging a piece of code in Odin.
The mistake was I had a matrix type and I called
mat[0][1], instead of mat[0,1].
It’s annoying to me that these both represent different things. I would prefer if mat[0][1] just errored out since it is inbuilt into the language. It would be nice to at least add this to the overview docs, I didn’t see it in the overview docs. I had to print every single value to figure this out.
Yes I made an account just to complain about this.
You can get your expected behavior only if you declare your matrix as #row_major, like so:
A := #row_major matrix[2, 3]f32 {}
assert(&A[0][1] == &A[0,1]) // true
B := matrix[2,3]f32 {}
assert(&B[0][1] == &B[1,0]) // true
In any language/library, one should always check whether matrices are stored in row-major or column-major form. Odin defaults to column-major storage as it’s more compatible with SIMD instructions.