# Internal representation of \`using Foo\`

**URL:** https://discourse.julialang.org/t/internal-representation-of-using-foo/19771
**Category:** Internals & Design
**Created:** [January 18, 2019, 8:09am UTC](https://discourse.julialang.org/t/internal-representation-of-using-foo/19771 "2019-01-18T08:09:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hhaensel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hhaensel/32/1207_2.png) [@hhaensel](https://discourse.julialang.org/u/hhaensel)
#### Post date: [January 18, 2019, 8:09am UTC](https://discourse.julialang.org/t/internal-representation-of-using-foo/19771/1 "2019-01-18T08:09:52Z")

</div>

When trying to make Lint.jl working in Juno with Julia 1.0.1, I realised that Lint would stumble across any line with `using [...]`.  
Digging into the root cause I found that `dump(:(using Foo))` has different results in different Julia versions:

```julia
julia-0.6.2.2> dump(:(using Foo))
Expr
  head: Symbol using
  args: Array{Any}((1,))
    1: Symbol Foo
  typ: Any

```

```julia
julia-1.0.1> dump(:(using Foo))
Expr
  head: Symbol using
  args: Array{Any}((1,))
    1: Expr
      head: Symbol .
      args: Array{Any}((1,))
        1: Symbol Foo

```

Is this by purpose? It seems a bit odd, as

```julia
julia-1.0.1> Expr(:using,:Foo)
:(using Foo)

```

but

```julia
julia-1.0.1> dump(Expr(:using,:Foo))
Expr
  head: Symbol using
  args: Array{Any}((1,))
    1: Symbol Foo

```

Maybe, I have missed something?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [January 18, 2019, 9:46am UTC](https://discourse.julialang.org/t/internal-representation-of-using-foo/19771/2 "2019-01-18T09:46:28Z")

</div>

> [@hhaensel](#):
>
> Is this by purpose?

The AST representation of various things was not stable prior to 1.0.

---

<div class="post-metadata">

### Author: ![hhaensel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hhaensel/32/1207_2.png) [@hhaensel](https://discourse.julialang.org/u/hhaensel)
#### Post date: [January 18, 2019, 10:32am UTC](https://discourse.julialang.org/t/internal-representation-of-using-foo/19771/3 "2019-01-18T10:32:56Z")

</div>

My concern is not so much the stability of AST between Julia versions, it is more that the output of `dump(Expr(:using,:Foo))` is not identical to `dump(:(using Foo))` although `Expr(:using,:Foo)` evaluates to `:(using Foo)`.  
Funny enough, `dump(Expr(:using,:Foo)) == dump(:(using Foo))` evaluates to `true` …

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [January 18, 2019, 10:53am UTC](https://discourse.julialang.org/t/internal-representation-of-using-foo/19771/4 "2019-01-18T10:53:45Z")

</div>

The expression type for using is [undocumented](https://docs.julialang.org/en/v1.2-dev/devdocs/ast/#Expr-types-1), you should consider opening an issue.

---

<div class="post-metadata">

### Author: ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)
#### Post date: [January 21, 2019, 10:36pm UTC](https://discourse.julialang.org/t/internal-representation-of-using-foo/19771/5 "2019-01-21T22:36:26Z")

</div>

Yes, this representation is intentional. The idea is that the `Expr` with head `.` is a “path expression”, a dot-delimited list of names giving the components of a module path. In general:

```julia
julia> dump(:(using A.B.C.D))
Expr
  head: Symbol using
  args: Array{Any}((1,))
    1: Expr
      head: Symbol .
      args: Array{Any}((4,))
        1: Symbol A
        2: Symbol B
        3: Symbol C
        4: Symbol D

```

So for `using A` the dot expression has a single argument.

Indeed there are a couple rough edges to fix here:

- The printing for `Expr(:using, :Foo)` should use that input form instead of `using Foo`, since as you note they don’t match.
- This should be added to the AST devdocs.
- There should be an error for evaluating `Expr(:using, :Foo)`, or perhaps we should treat it the same as `using Foo`.

> [@hhaensel](#):
>
> Funny enough, `dump(Expr(:using,:Foo)) == dump(:(using Foo))` evaluates to `true`

That would be because `dump` always returns `nothing`! 🙂
