RFC: consider @v macro for value indexing
Ref. #84, #117.
I don't intend/expect to merge this, mainly I put it up here as food for thought. I support using value indexing by default, but whatever the implementation I think there ought to be a first-class way to use normal indexing if desired (I would not be okay with having to do A.data[1,2] to use normal indices, for example). It would also be nice to provide some mechanism to adjust the tolerances when doing floating-point comparisons, though I feel less strongly about that since the default tolerances usually work fine.
This approach does not switch to value indexing by default, but provides (at least in my view) a convenient alternative that satisfies my concerns:
- Easy syntax
- Easy to splice in normal indexes where desired for mixed indexing
- Pretty obvious how to specify custom tolerances
- No breaking changes (which is nice, though it's not one of my main concerns)
It has some downsides:
- This is probably backwards. Indexes should be interpreted as values by default, and then perhaps we could have a macro like this to use normal/mixed indexing? Maybe there's a better way.
- No awareness of whether an array being indexed is actually an AxisArray, so one has to be a little careful. There's no way around this with a macro, apart from implementing generic fallback methods for how an AbstractArray should handle Value objects as indices, which seems clumsy.
-
@vis pretty terse for an exported symbol, but@valuewould be super annoying to type
This makes sense but doesn't address my use case; see comment at https://github.com/JuliaArrays/AxisArrays.jl/issues/117#issuecomment-328691769.