# Why does arrayref throw?

**URL:** https://discourse.julialang.org/t/why-does-arrayref-throw/104283
**Category:** New to Julia
**Tags:** question
**Created:** [September 26, 2023, 9:13pm UTC](https://discourse.julialang.org/t/why-does-arrayref-throw/104283 "2023-09-26T21:13:03Z")
**Posts on this page:** 1
**Showing post:** 86

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [October 13, 2023, 12:33am UTC](https://discourse.julialang.org/t/why-does-arrayref-throw/104283/86 "2023-10-13T00:33:34Z")

</div>

> [@nsajko](#):
>
> It’s a bit disappointing that the `isassigned` call isn’t optimized away, actually?

Figured it out, a package, UnsafeAssume is being [registered](https://github.com/JuliaRegistries/General/pull/93319). Example code for preventing undefined reference checks using the new package:

```julia
function unsafe_array_access(a)
  @inline begin
    unsafe_assume_condition(isassigned(a, 1))
    @inbounds a[1]
  end
end

```

EDIT:

Without thinking about the assembly generated (see my repo on Gitlab) for `unsafe_array_access` carefully:

1. It doesn’t include any branches or other conditional operations

2. the only instructions are push, mov, mov, mov, pop, ret

While I’m only guessing, I’d say the code is optimal (assuming no undefined references).

---

_[View the full topic](https://discourse.julialang.org/t/why-does-arrayref-throw/104283)._
