|
|
|
|
|
by bhnmmhmd
3256 days ago
|
|
The Python example looks really inspiring, and could possibly be implemented in future versions of Python. But as for your statement that "macros don't rely on homoiconicity", I find it hard to agree, because if that were the case, then why haven't Java or Python implemented the macro feature by now? |
|
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.