# Zero-based indexing ... (not) again

**URL:** <https://discourse.julialang.org/t/zero-based-indexing-not-again/100944>\
**Category:** General Usage\
**Created:** [June 28, 2023, 7:43pm UTC](https://discourse.julialang.org/t/zero-based-indexing-not-again/100944 "2023-06-28T19:43:31Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![bertschi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bertschi/32/33462_2.png) [@bertschi](https://discourse.julialang.org/u/bertschi)\
**Post date:** [June 29, 2023, 5:24pm UTC](https://discourse.julialang.org/t/zero-based-indexing-not-again/100944/8 "2023-06-29T17:24:27Z")

</div>

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

```julia
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.

---

_[View the full topic](https://discourse.julialang.org/t/zero-based-indexing-not-again/100944)._
