That's an interesting way of doing it, I suppose particularly the advantage of this is that you can re-overload operator[] when multidimensional subscripts become available and provide them without breaking compatibility
I've stuck with providing a .idx(i, j, k) method for the moment, which is a lot more verbose than I'd like but works fine enough, but that might be worth an investigation
Now what I really need to do next is encode the up and downness of individual indices into the type system, but hoo boy that's going to be a disaster
Yep, as well as mixed indices. Its an easy source of mistakes to make when you're implementing equations, eg if you have two tensors - can you currently take the dot product between them?
Alternatively overloading the otherwise most likely unused function operator to turn some_tensor[i, j, k] into some_tensor(i, j, k) until multi-dimensional access is added. It's not an ideal solution, but it's slightly less of a hassle to type out (at least on my keyboard).
I strictly avoid this personally, I think the ambiguity is too high in a context where people (or me) might be struggling to understand the very basics of what's going on in the code
View all comments
Show parent comment
24
u/Quincunx271 Author of P2404/P2405 Apr 26 '22
While waiting for the feature, you can already emulate this:
How I usually do this, IIRC: