Evaluating quoted variable binding

Skip to first unread message

Tomaž Žlender

Aug 14, 2016, 11:25:14 AM8/14/16
to elixir-lang-talk
Why does code

Code.eval_quoted(quote do: name = "Alexander")

evaluates to

{"Alexander", [{{:name, Elixir}, "Alexander"}]}

instead of binding "Alexander" to variable name same as it would if put in IEx directly as

name = "Alexander"

José Valim

Aug 14, 2016, 11:27:41 AM8/14/16
to elixir-l...@googlegroups.com
Variables inside quote have a context. Outside of a module, that context is Elixir. I believe we have more information in the docs for "quote".
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/1796a6e2-31dc-42ce-ad34-773d35498387%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


José Valim
Skype: jv.ptec
Founder and Director of R&D

Tomaž Žlender

Aug 16, 2016, 3:16:23 PM8/16/16
to elixir-lang-talk, jose....@plataformatec.com.br
Thanks for the answer José! Will check out the quote docs.

Dne nedelja, 14. avgust 2016 17.27.41 UTC+2 je oseba José Valim napisala:
Reply all
Reply to author
0 new messages