This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Source for wiki RedefiningSyntax version 2

author

cowan

comment


    

ipnr

127.10.177.1

name

RedefiningSyntax

readonly

0

text

This example determines what the behavior of the usual implementations is when an identifier is defined as a value and then redefined as syntax.  For example:

{{{
        (define (noodle) (foodle))
        (define (foodle) 23)
        (noodle) => ??
        
        (define-syntax foodle (syntax-rules ()
          ((foodle) 17)))
        (noodle) => ??
        
        (define (noodle) (foodle))
        (noodle) => ??
}}}

Essentially all the implementations that support `syntax-rules` behave the same way on the first and third calls to `noodle`, returning 23 and 17 respectively.  The exception is Owl Lisp, which has a hyperstatic REPL that disallows all forward references.

The first definition of `noodle` refers to `foodle`, which is undefined, and is therefore assumed to be a variable.  (Guile prints a warning at this point.)  The second definition of `noodle` refers to the current (syntax) definition of `foodle`.  The question is, what happens in the second call of `noodle`, when the first definition of `noodle` is being invoked, but the definition of `foodle` has changed out from under it?

`Noodle` continues to call the old definition of `foodle` and returns 23:  Racket, Gambit, Chicken, Bigloo, Scheme48/scsh, SISC, Chez, Vicare, Larceny, Mosh, !IronScheme, STklos, KSi, !SigScheme, SXM, Chibi

Complains that a non-procedure is being invoked:  Gauche, MIT, Guile, Kawa, SCM, Foment, Scheme 9

Complains that `foodle` is not defined: Ypsilon

No support for `syntax-rules`: NexJ, JScheme, KSi, !SigScheme, Shoe, !TinyScheme, RScheme, S7, BDC, XLisp, Rep, Schemik, UMB, Elk, Llava, Sizzle, !FemtoLisp, Dfsch, Inlab

time

2014-01-07 10:20:58

version

2