Live data from Hacker News

How to properly use macros in C

pmihaylov.com

51–52 of 52 posts

Re: How to properly use macros in C

#51

Earlier quoted context omitted.

Lisp macros directly manipulate the program's abstract syntax tree (in the case of Lisp, it happens to hava a 1-1 relationship to the source code structure). It's more comparable to a web app's html templater than a syntactic macro system like Lisp's.

It doesn't strictly have a 1-1 relationship because of macros themselves. They're Turing complete, so the same macro can expand into different ASTs based on user input during compilation, presence of any files on the hard drive or even moon phases, so I have to say that this relationship is much more complicated than a simple 1-1. For very simple functions like (lambda (x) (* x x)) this is true, but macros' power gre…

A Lisp form with unexpanded macros has abstract syntax; the unexpanded macro forms are AST material.

Re: How to properly use macros in C

#52
post #9

One strange phenomenon when coding in C is using macros. This is not something which can be seen in other programming languages (other than C++). This is false. Lisp is a language, or rather, a family of languages, where macros play a giant role, and the author does not seem to mention them. But again, Lisps generally have more powerful macros than C does - they allow for arbitrary compile-time computation.

People who know Lisp are unlikely to be writing blogs about using macros in C. C and C++ blogs generally tend to be of poor quality, because most of the people writing such things are excited newbies who have fewer years of experience than real experts have abstinence .

While your comment provides no evidence in support of its contention, it does support the notion that Lisp programmers have excessive hubris.
Post reply on HN