Earlier quoted context omitted.
The reason Linux trace macros are insane is because C preprocessor is so primitive. Think about it. > they are quite powerful For small values of "quite". C macros are strictly less (and by large margin powerful than Lisp macros. One can't even use #ifdef inside #define!
Note, the power of the macro system is not equal to its general good. The C macro system was already too powerful, and one of the things that hurts languages is a preprocessor of virtually any kind. The badness of the C preprocessor starts much earlier with things like include files, and the fact that you can't statically analyze the code in any reasonable way. The benefit from the preprocessor is absurdly small. Wit…
How Lisp macros differ from static code-generation and metaprogramming
61–70 of 84 posts
Re: How Lisp macros differ from static code-generation and metaprogramming
#62A key tradeoff is that they must be expanded at run-time, and in doing so they incur a performance penalty that doesn't exist with compile-time macros.
Re: How Lisp macros differ from static code-generation and metaprogramming
#63Earlier quoted context omitted.
Note, the power of the macro system is not equal to its general good. The C macro system was already too powerful, and one of the things that hurts languages is a preprocessor of virtually any kind. The badness of the C preprocessor starts much earlier with things like include files, and the fact that you can't statically analyze the code in any reasonable way. The benefit from the preprocessor is absurdly small. Wit…
It took five years for LINQ to be added to C# because it was too painful for anyone other than Microsoft to add any syntax to the language. Macros would have fixed that.
Re: How Lisp macros differ from static code-generation and metaprogramming
#64A couple points on the metaprogramming space (these aren't about the article, but the article reminded me of them): 1. Macros aren't unique to lisp. They're most developed and used in the lisp family, but you don't need to have a homoiconic language to have macros. The Mirah programming language--statically typed Ruby on the JVM--has non-hygenic macros, I know there's been a number of efforts to add macros to coffees…
Re: How Lisp macros differ from static code-generation and metaprogramming
#65Earlier quoted context omitted.
Note, the power of the macro system is not equal to its general good. The C macro system was already too powerful, and one of the things that hurts languages is a preprocessor of virtually any kind. The badness of the C preprocessor starts much earlier with things like include files, and the fact that you can't statically analyze the code in any reasonable way. The benefit from the preprocessor is absurdly small. Wit…
It took five years for LINQ to be added to C# because it was too painful for anyone other than Microsoft to add any syntax to the language. Macros would have fixed that.
Re: How Lisp macros differ from static code-generation and metaprogramming
#66So Lisp macros provide compile-time code generation, but in doing so, you have access not just to the code-generation instructions – which are just Lisp data – but also to the entire Lisp language and environment. The same can be said for classic Forth. Indeed, the enthusiastic way that Lispers describe macros I find eerily similar to how I used to hear Forthians describe their language. Except in Forth the relevant…
Forth is almost the complete opposite of Lisp, and thus very similar.
Re: How Lisp macros differ from static code-generation and metaprogramming
#67i wish authors didnt craft their arguments around C/Java.
Re: How Lisp macros differ from static code-generation and metaprogramming
#68 > Except, of course, that doesn’t work. The preprocessor
> only makes one pass through the file, meaning a macro
> can’t call another macro.
macro.c:
#include
#define LOOP(n) for (int i = 0; i
Of course macros can call other macros:
http://gcc.gnu.org/onlinedocs/cppinternals/Macro-Expansion.h...Ignoring his poorly protected macros, and taking nothing away from Lisp, am I missing some subtle point he's making, or is the author just flat out wrong here? I think he's just wrong, and this makes it hard for me to even read the rest of his argument.
Re: How Lisp macros differ from static code-generation and metaprogramming
#69> Except, of course, that doesn’t work. The preprocessor > only makes one pass through the file, meaning a macro > can’t call another macro. macro.c: #include #define LOOP(n) for (int i = 0; i Of course macros can call other macros: http://gcc.gnu.org/onlinedocs/cppinternals/Macro-Expansion.h... Ignoring his poorly protected macros, and taking nothing away from Lisp, am I missing some subtle point he's making, or is…
Re: How Lisp macros differ from static code-generation and metaprogramming
#70> Except, of course, that doesn’t work. The preprocessor > only makes one pass through the file, meaning a macro > can’t call another macro. macro.c: #include #define LOOP(n) for (int i = 0; i Of course macros can call other macros: http://gcc.gnu.org/onlinedocs/cppinternals/Macro-Expansion.h... Ignoring his poorly protected macros, and taking nothing away from Lisp, am I missing some subtle point he's making, or is…
(a nonsensical example, as I can't think of a proper one right now)
#define PRINTFOO PRINTBAR
#define PRINTBAR PRINTFOO
PRINTFOO
The ANSI C standard says a macro, while it is being expanded by the preprocessor, ``is painted blue'' (is no subject to further expansion).
I'm not sure, but probably it follows the C macros are not Turing-complete.
EDIT: on the other hand, a LISP macro system is a Turing-complete programming language that's geared towards manipulating lists of symbols and values (which, incidentally, is LISP program).