[ERR5RS] Bindings in R5RS vs R6RS

AndrevanTonder andre at het.brown.edu
Sun Sep 16 08:35:16 PDT 2007


On Sat, 15 Sep 2007, Jonathan A Rees wrote:

> There is no clear or principled interaction semantics, but I think
> there could be with some work. You can't set! imported bindings, but
> you can always shadow them. If you haven't permitted integration then
> this always does something perfectly clear and, importantly, in
> keeping with R5RS. (Scheme48 is slavish to R5RS, or has been so far.)

I guess one way of framing the question is what lexical scoping
should mean at the top level.  R6RS made the decision that the
region of a top level binding should be the entire top level.
Whatever its disadvantages, this is very simple.

If one is to allow top level shadowing, it is
not clear, at least to me, how one would simply describe the
correct behaviour in the following cases.  The difficulty
of the issue is reflected in the fact that different Scheme
implementations give different answers for some of these.
More troubling, it is difficult to come up with a self-consistent
and simple definition "regions" that is consistent across all
these cases.  Any definition of region I could come up with
works in a couple of cases and then fails on another.

   (define (f) x)
   (define x 1)
   (f)
----
   (define (f) car)
   (define car 1)
   (f)
----
   (define x car)
   (define car 1)
   x
----
   (define car
     (let ((old-car car))
       (lambda () (old-car '(1 2)))))
   (car)
----
   (define-syntax foo
    (syntax-rules ()
      ((_) 1)))
   (define-syntax bar
     (syntax-rules ()
       ((_) (foo)))
   (define-syntax foo
    (syntax-rules ()
      ((_) 2)))
   (bar)
----
   ; assuming imports
   (define (x) 1)
   (define (f) x)
   (f)
   (import (only (foo) x))
   (f)
----
   (define-syntax x
     (syntax-rules ()
       ((_) 1)))
   (define (f) (x))
   (f)
   (import (only (foo) x))
   (f)

In the end, I don't blame R6RS for avoiding the issue.

Andre



More information about the Err5rs mailing list