|
|
|
|
|
by bananicorn
3203 days ago
|
|
They work something like this in LISPs, right?
Like, can you define new language constructs with them? http://www.red-lang.org/2016/12/entering-world-of-macros.htm... (BTW, have a look at red for desktop apps, it's not even at 1.0 and already fucking amazing) But on topic; Are Macros a well-defined "thing"?
Since a macro in C, seems to be rather different from a RED or LISP Macro. Or is it just that C macros are essentially the same, just more restricted? |
|
Lisp macros access the input program fragment as structured data, and manipulate that using the same Lisp functions and data structures that you use for regular, normal Lisp code.
I think that both forms are technically Turing-Complete, but Lisp is more expressive. In particular, it's much more common to see Lisp macros that destructure and reform their inputs, where C macros tend to see their inputs as black boxes that can't be opened. The textual-substitution model of C also has some extra perils, because code fragments can be context sensitive (such as creating identifiers that are already in scope).
In both cases, Macros are well-defined "things" in the sense that they are thoroughly defined in their respective language documents, but in both cases they are not first-class language items because they don't exist at run-time.