[r6rs-discuss] Macro expansion erratum

Robert Ransom rransom.8774 at gmail.com
Sat Feb 27 04:40:38 EST 2010


At the end of §12.1, the R6RS library report states: “An algebra that
defines how marks and substitutions work more precisely is given in
section 2.4 of Oscar Waddell's PhD thesis.”  This citation is in
error -- the algorithm specified in the cited work is not consistent
with, and its behaviour is not compatible with, statements in R6RS
itself about the intended expansion algorithm.

The core inconsistency is that, while R6RS specifies that
(BOUND-IDENTIFIER=? X Y) is #T if and only if X and Y have the same
name and ‘marks’, Waddell's thesis specifies that (BOUND-IDENTIFIER=? X
Y) is #T if and only if X and Y have the same marks and
(FREE-IDENTIFIER=? X Y) is #T. (See pages 44 and 49 (PDF p. 60 and
65).)  This inconsistency affects the expansion process, as both
documents specify that if an identifier is bound by LAMBDA, LET-SYNTAX,
or LETREC-SYNTAX, all identifiers in the binding's scope which are
BOUND-IDENTIFIER=? to the bound identifier are affected by the
binding.  (In R6RS, see the second-to-last paragraph of library §12.1
and the specification of BOUND-IDENTIFIER=?.)

The above inconsistency between the internal behaviours of the R6RS and
Waddell expansion algorithms leads to incompatible behaviour between
the two algorithms.  If expanded with the R6RS expansion algorithm,
TEST-FUNC in the following library returns the R6RS CONS function; if
expanded with Waddell's algorithm, TEST-FUNC returns 2.

(library (export test-func)
         (import (rnrs base (6))
                 (prefix (rnrs base (6)) foo:))
  (define (test-func)
    (let ((cons 2))
      foo:cons)))

For these reasons, the citation of Oscar Waddell's thesis should be
listed as an erratum in R6RS, and, if possible, the erratum should
provide a reference to the actual source of the algorithm described in
R6RS.

Robert Ransom



More information about the r6rs-discuss mailing list