Hi,
I have been coding with Elixir for 9+ months and I encountered several time the concept of quotes and each time, I think “ok, today I shall be mature enough to understand quotes”, re-read the content I can find on the internet (starting with the getting started).
But until now, I still haven’t understood the blood out of it.
My main question is why do we need them?
If quoting is only about changing the representation of a piece of code, then why should it be so different quoted than unquoted. I’m comfortable with the concept of AST, but as for me it only changes the representation of something, not its content.
Eg. 1 + (2 + 3) <==> add(1, add(2, 3))
Besides, it feels illogical to me that there are two worlds: the quoted one and the unquoted. If quoting is about meta-programming, then quoting quoted expressions should make sense to program meta-meta-programming, shouldn’t it?
Someone in this forum suggested that macros (that are closely related to quotes, aren’t they?) should be seen as functions that return other functions instead of expressions. This helped me a little to read some quote-using-code, but it still doesn’t explain why we need them.
I am comfortable with currying, partial application, function as references, which are the way meta-programming goes in languages I’m more comfortable with (JS, Haskell …), so what’s different here?
Finally, are quotes so hard to understand or is it just me?
Of course, I feel like this is key concept to be comfortable with Elixir, I can be patient with that, just like I was (am?) with Haskell’s monads, but nothing out there suggests that this one has to expect something hard so it may be just me…
Thanks for the help, hope this can be useful to others!