# Trying to figure out what a \[\] \[\] does in a macro assignment

**URL:** <https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 20, 2022, 7:54pm UTC](https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556 "2022-11-20T19:54:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)\
**Post date:** [November 20, 2022, 7:54pm UTC](https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556/1 "2022-11-20T19:54:39Z")

</div>

noob here. Trying to understand some code and am baffled as to how to figure out the utility of the TWO in the below.

```julia
@use_memo(deps::Vector{Any}) do
# Expensive computation/loading
end

messages = @use_memo(() -> [], [] ) # THIS IS THE CODE THAT CONFUSES ME

```

Running it in the repl I see it returns a vector of any BUT I don’t understand what’s going on? what is an alias for Array and why is it useful?

```julia
using PlutoHooks

julia> messages = @use_memo(() -> [], [])
Any[]

julia> typeof( messages)
Vector{Any} (alias for Array{Any, 1})

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 20, 2022, 8:11pm UTC](https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556/2 "2022-11-20T20:11:48Z")

</div>

You can use `@macroexpand` to see what the macro expands to.

> [@1153dent](#):
>
> what is an alias for Array and why is it useful?

That’s just the way type aliases are printed in the REPL.

---

<div class="post-metadata">

**Author:** ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)\
**Post date:** [November 20, 2022, 8:21pm UTC](https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556/3 "2022-11-20T20:21:36Z")

</div>

Hi there  
thanks for the reply @kristoffer.carlsson BUT I tried that and got

```julia
ulia> using PlutoHooks

julia> messages = @use_memo(() -> [], [] )
Any[]

julia> @macroexpand( @use_memo() )
ERROR: MethodError: no method matching var"@use_memo"(::LineNumberNode, ::Module)
Closest candidates are:
  var"@use_memo"(::LineNumberNode, ::Module, ::Any, ::Any) at ~/.julia/packages/PlutoHooks/udh31/src/notebook.jl:56
Stacktrace:
 [1] #macroexpand#61
   @ ./expr.jl:115 [inlined]
 [2] top-level scope
   @ REPL[3]:1

julia> @macroexpand( @use_memo )
ERROR: MethodError: no method matching var"@use_memo"(::LineNumberNode, ::Module)
Closest candidates are:
  var"@use_memo"(::LineNumberNode, ::Module, ::Any, ::Any) at ~/.julia/packages/PlutoHooks/udh31/src/notebook.jl:56
Stacktrace:
 [1] #macroexpand#61
   @ ./expr.jl:115 [inlined]
 [2] top-level scope
   @ REPL[4]:1

julia> 

```

what am I missing please?

---

<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:** [November 20, 2022, 8:27pm UTC](https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556/4 "2022-11-20T20:27:11Z")

</div>

The macro call `@use_memo(() -> [], [] )` is working, but your trying to expand the `@use_memo()` which is not working as the macro requires two arguments. Just try

```julia
@macroexpand @use_memo(() -> [], [] )

```

---

<div class="post-metadata">

**Author:** ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)\
**Post date:** [November 20, 2022, 8:40pm UTC](https://discourse.julialang.org/t/trying-to-figure-out-what-a-does-in-a-macro-assignment/90556/5 "2022-11-20T20:40:07Z")

</div>

thanks @bertschi

one step forward several thousand back 🙂

serves me right for :

- trying to dodge metaprogramming
- lifting the @macroexpand rock

thanks for taking the time both @bertschi and @kristoffer.carlsson

```julia
 @macroexpand @use_memo(() -> [], [] )
quote
    #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:58 =#
    var"#1#ref" = begin
            #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:112 =#
            var"#1#ref" = Base.RefValue{Any}(#undef)
            #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:113 =#
            var"#1#ref"[] = PlutoHooks.nothing
            #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:114 =#
            var"#1#ref"
        end
    #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:59 =#
    if #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:334 =#, [], #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:335 =#, true
        #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:60 =#
        var"#1#ref"[] = ((()->begin
                    #= REPL[2]:1 =#
                    []
                end))()
    end
    #= /home/dave/.julia/packages/PlutoHooks/udh31/src/notebook.jl:62 =#
    var"#1#ref"[]
end

julia> 

```
