Is it allow to return an array from a macro and where is this documented?
Can I for example return an array of quoted functions or quoted modules?
I have returned an array of quoted modules and they get defined BUT I cannot find if this is supported or if I should better return only one quoted block.
No. At least not if you are talking about
:arrays from the erlang stdlib. Probably not if you are talking about any other array like datastructure…
If though by “array” you mean a list, just because of the bracket syntax, yes thats fine. At least as long as its elements are valid AST.
I’m not sure if it is documented somewhere, but I already learned that an
quotes in the functions body worked as expected. As you learned as well.
After some years of elixir beeing 1.x you can totally rely on this. I’ve seen similar expectations often in the wild and I think I have even seen it in the elixir code base. So if this would ever change before 2.0 I’d consider it a breaking change that would require a major version bump.
Yes, you guess right, I meant List! Thank you.
The reason why this works is also that lists are literals when quoted. So:
quote(do: [foo, bar])
is exactly the same as:
[quote(do: foo), quote(do: bar)]