[R6RS] When do define-bound variables get bound?

R. Kent Dybvig dyb at cs.indiana.edu
Wed Jan 10 09:45:49 EST 2007


> Robby noticed this when writing the semantics:
>
> How should
>
> (define x y)
> (define y ...)
>
> and
>
> (define x x)
>
> behave?

Both must raise exceptions because a RHS references a location that has
not yet been given a value.

> We have this wording:
>
> >   This binds \hyper{variable} to a new location before assigning the
> >   value of \hyper{expression} to it.
>
> ... which seems to suggest that the location is only created when
> evaluation gets to the definition (and filled with an unspecified
> value), just before the rhs expression is evaluated.
>
> Am I right?

The present wording notwithstanding, all of the locations must be created
before any of the definition RHS expressions are evaluated to allow mutual
recursion, as in a letrec or letrec* expression.

Kent



More information about the R6RS mailing list