Evaluating quoted variable binding

已查看 54 次
跳至第一个未读帖子

Tomaž Žlender

未读,
2016年8月14日 11:25:142016/8/14
收件人 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

未读,
2016年8月14日 11:27:412016/8/14
收件人 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

未读,
2016年8月16日 15:16:232016/8/16
收件人 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:
回复全部
回复作者
转发
0 个新帖子