Find Related products on Amazon

Shop on Amazon

Extending a Language – Writing Powerful Macros in Scheme

Published on: 2025-07-21 18:07:36

The Lisp languages, and thus Scheme as well, are homoiconic programming languages, which means that if the program's internal representation is a datum of the language. In first approximation, the internal representation of a Scheme expression (as of a Scheme program) is a Scheme datum value. For example, the program (expression) ( let ([x 1]) (+ x 2)) is represented by a list whose first element is the symbol let , whose second element is a list of a list with two elements and whose third element is a list of the three data + , x , and 2 . Due to existence of hygienic macros we have to amend this traditional picture. Consider the following example. ( let ([ set! 10]) (incr! set!) set!) To evaluate the let expression, the macro use of incr! has to be expanded first. After the expansion, the expression would look like ( let ([ set! 10]) ( set! set! (+ set! 1)) set!) if Scheme expressions were represented by Scheme datum values and within, identifiers were represented by symbols. ... Read full article.