Future directions of Julia

OffsetArrays is a nice user-level way to handle that, but it’s not a nice library-level way to handle such an input. For example, in a differential equation solver, optimization library, etc., you just stick to linear algebra, broadcast, iteration with eachindex, start, first, and those primitives that do not assume 1:length(a). If you do this, then your whole library will support OffsetArrays even if your library does not depend on OffsetArrays or make reference to them. In that sense, the mathematical algorithm is abstracted to work with any array type reguardless of their indexing structure, which is different many more general than “any instance of an OffsetArray”.

So then,

If everyone is writing algorithms that, instead of doing if typeof(x) <: OffsetArrays but instead making it naturally offset-aware, the beauty is that if you want different syntax you can just make it. Make a new library OffsetArrays2.jl with an @OA real, dimension(-1:1, 0:4) :: A = 0.0 if you want, the world is your oyster. You’d then be able to use that in any general library. So we can have 10 packages exploring the syntax, some trying to make new better general syntax while others simply making arrays offset for very specific purposes.

9 Likes