Zero-based indexing ... (not) again

Good points, the macro is indeed much more brittle than I had hoped for. Here are some more issues:

julia> @absolutezero x[0:end]
ERROR: BoundsError: attempt to access 9-element UnitRange{Int64} at index [1:10]

julia> @absolutezero @views x[0]
1

julia> @views @absolutezero x[0]
ERROR: BoundsError: attempt to access 9-element UnitRange{Int64} at index [0]

Seems that changing indexing should be used sparingly, i.e., either locally as @absolutezero tried or more globally as OffsetArrays. Imho the latter is actually worse as it might break in generic code without any hint – lexical, visual or otherwise – of where the problem is lurking.

1 Like