

Clojure from the ground up: macros (2013) - michaelsbradley
https://aphyr.com/posts/305-clojure-from-the-ground-up-macros

======
xiaq
Nice article, but

> There is another key difference between Lisp macros and many other macro
> systems: in Lisp, the macros operate on expressions: the data structure of
> the code itself. Because Lisp code is written explicitly as a data
> structure, a tree made out of lists, this transformation is natural.

The author seems to be consciously avoiding "homoiconity", but this is still
yelling "homoiconity". And "homoiconity" makes absolutely no sense. The source
code of _every_ programming language is an AST literal, and in principle every
language can have macros by allowing compile-time AST to AST functions. This
is precisely what has happened with Scala.

The only thing special about Lisp is that the AST is a list, whose operations
are familiar to the programmer. With other languages the programmer has to
learn some specialized API to write macros. The advantage of Lisp macros is
that they are easier to write (than say, Scala macros), but this extra
expressing power is enabled by having macros themselves instead of having
"homoiconity".

~~~
i_s
> And "homoiconity" makes absolutely no sense. The source code of every
> programming language is an AST literal, and in principle every language can
> have macros by allowing compile-time AST to AST functions.

It makes perfect sense. Yes, the source code of every language is an AST
literal, but it matters a great deal for metaprogramming how close it is to
its internal structure.

> The only thing special about Lisp is that the AST is a list, whose
> operations are familiar to the programmer. With other languages the
> programmer has to learn some specialized API to write macros. The advantage
> of Lisp macros is that they are easier to write (than say, Scala macros),
> but this extra expressing power is enabled by having macros themselves
> instead of having "homoiconity".

Who are you disagreeing with? I don't think anyone has said macros are
impossible in languages other than Lisp.

You are also contradicting yourself here, because "expressive power" and
"easier to write" are not independent.

