I have a macro to define a function where one of the parameters is the AST
of the function body. But I can't work out how to insert the AST. Example:
defmacro define_do_cardinal(rules, locale) do
quote do
defp do_cardinal(unquote(locale), n, i, v, w, f, t), do:
unquote(rules)
end
end
unquote(rules) won't do it since unquoting doesn't add the code to the
function it just inserts the AST as a literal. I could, I suppose, hand
craft the function header AST and insert the function body AST but that
seems more work than I would expect.
Is there a way to insert an AST as the code for a function body?
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-talk/34402692-3d20-447f-aca4-7e815d7badcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.