Get the latest tech news

C++ Template Macroprogramming versus Lisp Macros


Following on from Lisp macros versus Rust macros, I also want to compare C++ templates to Lisp macros. Templates in C++ were designed as a way of generating typed versions of classes.

Also as with Rust, use of templates is semantically and syntactically distinct from “normal” C++ code or syntax, and it’s this that causes the programming load. We can show this by taking a factorial function written in “normal” Lisp and macro-ifying it to be computed at compile-time: More importantly, Lisp (and indeed Rust) macro can abstract over syntax as well as classes and values, and so allow the language to be extended with new first-class-at-compile-time structures.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Lisp Macros

Lisp Macros

Related news:

News photo

Defense of Lisp macros: The automotive field as a case in point