|
|
|
|
|
by dan-robertson
1608 days ago
|
|
The frustration of Julia macros for me was never knowing what AST would be produced for a given expression. This is a bit more manageable if you have a typed AST (e.g. OCaml but ppxes have other issues) or an obvious one (e.g. lisp). I like the way rust handles it where the macros operate on a tree of non-delimiter leaves and [delimiter, subtree list, delimiter] nodes which can allow for figuring out what the input to a macro will be more easily and for more varied macro syntax. Other languages that want a full AST before macros force the macro input to be a bit more AST-like, e.g. the Julia parser picks operator precedence and OCaml won’t let you use _ as an identifier. Maybe it is better now but when I looked at macros ~5 years ago some language update changed the ast produced by the parser and I basically gave up. I like that Julia offers some macro-like techniques that replace a lot of the cases where one might use a macro for performance reasons. |
|