My array proposals included some form of specifying storage ranks for each 
extent. By default, the ranks would follow row-major order, like C. The first 
dimension would have the widest span between elements that differ by 1 in the 
first index and are the same for other indexes. The last dimension would have 
elements that differ by 1 in the last index and are the same for other indexes 
be adjacent in memory.

Overriding the ranks would change the numbers in the offset vector, which is 
combined with the index vector via the dot product to determine the memory 
offset of the desired element. The most common use for this is specifying 
column-major order, like Fortran. But recently I realized that I may have been 
too theoretical; Fortran-compatibility isn’t the most common use, but the only 
use. Is there any application for arbitrary storage ranks? (For N extents, 
there are N! possible storage ranks.) I’ve never heard of any other orders 
besides row- and column-majors.

You can implement column-major array indexing by reversing the order of indexes 
before dereference. This means if static-sized arrays get added to Swift, and 
value-based generic parameters and variadic generic parameters also get added, 
then a column-major array could be implemented as a library type. I think I’ll 
go with that, unless there’s a pressing need for column-major or 
arbitrary-ranked arrays out there.

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to