# Method variable names and destructuring

**URL:** <https://discourse.julialang.org/t/method-variable-names-and-destructuring/14664>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [September 7, 2018, 2:34pm UTC](https://discourse.julialang.org/t/method-variable-names-and-destructuring/14664 "2018-09-07T14:34:44Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [September 7, 2018, 2:34pm UTC](https://discourse.julialang.org/t/method-variable-names-and-destructuring/14664/1 "2018-09-07T14:34:44Z")

</div>

I am trying to fix [DocStringExtensions.jl/issues/67](https://github.com/JuliaDocs/DocStringExtensions.jl/issues/67), for which I need to get the variable names also for destructured arguments. MWE:

```julia
f((x, y), z) = x + y + z
## how to extract something like
((:x, :y), :z)
## from
first(methods(f))

```

---

<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:** [September 7, 2018, 3:03pm UTC](https://discourse.julialang.org/t/method-variable-names-and-destructuring/14664/2 "2018-09-07T15:03:20Z")

</div>

I don’t think that `x` and `y` exists in the method signature after lowering but that this instead gets transformed to

```julia
function f(__xy, z)
    x, y = __xy
    return x + y + z
end

```

I guess the lowered form could be analyzed and retrieve back the original variable names but it requires a bit more work

```julia
julia> Meta.lower(Main, :(f((x, y), z) = x + y + z))
:($(Expr(:thunk, CodeInfo(
 1 ─ $(Expr(:method, :f)) │
 │ %2 = (Core.Typeof)(f) │
 │ %3 = (Core.svec)(%2, Core.Any, Core.Any) │
 │ %4 = (Core.svec)() │
 │ %5 = (Core.svec)(%3, %4) │
 │ $(Expr(:method, :f, :(%5), CodeInfo(quote │
    (Base.indexed_iterate)(#temp#@_2, 1)
    x = (Core.getfield)(%1, 1)
    #temp#@_6 = (Core.getfield)(%1, 2)
    (Base.indexed_iterate)(#temp#@_2, 2, #temp#@_6)
    y = (Core.getfield)(%4, 1)
    #temp#@_6 = (Core.getfield)(%4, 2)
    x + y + z
    return %7
end)))
 └── return f │
))))

```
