11 ms·
There's a very steep tradeoff between the approachability of a macro and that of its expander code. Look at Rust macro_rules!, or Scala macros, or Template Hask
by erik_seaberg 2y ago
There's a very steep tradeoff between the approachability of a macro and that of its expander code. Look at Rust macro_rules!, or Scala macros, or Template Haskell. A formal grammar can define a strongly-typed deeply hierarchical data structure, but the code to drill in and map to a different deeply hierarchical data structure by hand seems to become a nightmare. Even Scheme hygenic macros are noticeably harder than "take a macro call as a list, use quasiquote to return a list that starts with PROGN" which makes it actually feasible (if risky!) to start cranking out macro expanders.
- krschacht 2y agoYes, I’ve been wondering if this is the core tradeoff. Especially as I compare Arc to Ruby. I love the readability of ruby code, but it’s easy for the meta programming to become very difficult to read. The language is quite flexible, but it’s not easy to change in the ways you want. Whereas Arc Lisp’s code is much more difficult to read, but the macro syntax is very elegant for an incredible amount of flexibility.