▲ | WalterBright 2 days ago | |||||||||||||||||||||||||||||||||||||||||||||||||
A lot of people disagree with me on that. Wait till they try to get other people to understand their code :-/ Me, I've eliminated nearly all the use of macros from my old C code that is still around. The code is better. I suspect that heavy use of macros is why Lisp has never become mainstream. | ||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | kazinator 2 days ago | parent [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
Heavy use of macros could be why C went mainstream. Macros gave C efficient inline functions without anything having to be done in the compiler. Doing things like "#define velocity(p) (p)->velocity" would instantly give a rudimentary C compiler with no inline functions a performance advantage over a crappy Pascal or Modula compiler with no inline functions, while keeping the code abstract. And of course #if and #ifdef greatly help with situations where C does not live up to its poorly deserved portability reputation. In languages without #ifdef, you would have to clone an entire source file and write it differently for another platform, which would cause a proliferation due to minor differences (e.g. among Unixes). Ah, speaking of which; C's #ifdef allowed everyone to have their own incompatible flavor of Unix with its own different API's and header files, yet get the same programs working. An operating system based on a language without preprocessing would have hopelessly fragmented if treated the same way, or else stagnated due to discouraging local development. Thanks in part to macros, Lisp people were similarly able to use each other code (or at least ideas) in spite of working on different dialects at different sites. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|