# Namespace with lexical access

**URL:** <https://discourse.julialang.org/t/namespace-with-lexical-access/68010>\
**Category:** General Usage\
**Tags:** namespaces\
**Created:** [September 10, 2021, 9:30pm UTC](https://discourse.julialang.org/t/namespace-with-lexical-access/68010 "2021-09-10T21:30:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [September 10, 2021, 9:30pm UTC](https://discourse.julialang.org/t/namespace-with-lexical-access/68010/1 "2021-09-10T21:30:51Z")

</div>

I often want to use a namespace for calculating stuff like this

```julia
FOO = 1

namespace A
x = FOO + 1
end

```

This is almost like a module except modules need to import names from the enclosing lexical module, which can be inconvenient. Is it possible to make a namespace where lexically prior names are accessible?

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [September 10, 2021, 9:46pm UTC](https://discourse.julialang.org/t/namespace-with-lexical-access/68010/2 "2021-09-10T21:46:50Z")

</div>

I guess you can do that as

```julia
const A = let
    x = FOO + 1
    #= some more expressions =#
    (; x, #= and other bindings you'd like to export =#)
end

```

The “exported” names can only be used as `A.x` etc., however.
