thank you Jose.
`binding()[:a]` is the way to go.
iex> a = 1
...> binding()[:a]
1
Just for the record of anybody in the list or Googling this, to achieve this with macros one can do:
iex> a = 1
...> quote(do: var!(unquote(Macro.var(:a, nil)))) |> Code.eval_quoted(binding) |> elem(0)
1
or simply
...> quote(do: var!(unquote({:a, [], nil}))) |> Code.eval_quoted(binding) |> elem(0)
1
if anybody else knows a simpler way, please let me know.
On Thu, 14 Jul 2016 18:02:34 +0200
José Valim <
jose....@plataformatec.com.br> wrote:
> You need to pass your binding to eval quoted, see Kernel.binding/0.
> That will return all variables up to some point. However, you will
> also see binding is a keyword list, so you can simply get the
> variable value directly from it.
>
>
>
> *José Valim*