Hacker News new | ask | show | jobs
by jwdunne 3253 days ago
Macros don't rely on homoiconicity. The raw power of Lisp macros rely on it. This is because, as you know, lisp code is lisp data. All of the functions for manipulating lists, which form the basis of a lisp language, can be used to build and emit code.

In reality, lisp macros are functions that accept lists and emit lists. The difference is they operate at compile time, so they transform code.

In fact, a common macro implementation pattern is to delegate the actual work to a function that transforms lists, with the macro passing the code as a list and returning the resultant list as expanded code. I imagine this makes macros an order of magnitude easier to test.

In other languages, it's possible and can be done as in Rust etc. It's just far far more natural to do so in a homoiconic language due to the above.