# Scopes: accessing a global variable hidden by a local of the same name

**URL:** <https://discourse.julialang.org/t/scopes-accessing-a-global-variable-hidden-by-a-local-of-the-same-name/107253>\
**Category:** New to Julia\
**Tags:** question, scope\
**Created:** [December 7, 2023, 5:18am UTC](https://discourse.julialang.org/t/scopes-accessing-a-global-variable-hidden-by-a-local-of-the-same-name/107253 "2023-12-07T05:18:28Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [December 9, 2023, 7:43pm UTC](https://discourse.julialang.org/t/scopes-accessing-a-global-variable-hidden-by-a-local-of-the-same-name/107253/18 "2023-12-09T19:43:56Z")

</div>

The type stability definitely helps, but yeah there’s extra work in retrieving the value from the heap. I don’t know if dereferencing happens every time the variable is used or if the compiler tries to reduce it, I would need to learn how to read `@code_llvm`. There’s an extra layer to it where a typed global`::T` need [more dereferencing](https://discourse.julialang.org/t/why-is-accessing-a-typed-global-different-from-dereferencing-a-const-ref/102992/11) than a `const` `Ref{T}`.

---

_[View the full topic](https://discourse.julialang.org/t/scopes-accessing-a-global-variable-hidden-by-a-local-of-the-same-name/107253)._
