bug in psyntax?

Matthias Radestock <[email protected]>
Newsgroups gmane.comp.java.sisc.devel
Message-ID <[email protected]>
(let ((x 1))
   (let-syntax ([foo (syntax-rules () ((_) 2))])
     (define x (foo))
     3)
   x)

=> 2

(sc-expand '(let ((x 1))
               (let-syntax ([foo (syntax-rules () ((_) 2))])
                 (define x (foo))
                 3)
               x))

=>

((lambda (|x_GAX0qWu6h|)
    (letrec ((|x_GAFKfbx6h| '2))
      (begin '3 |x_GAFKfbx6h|)))
  '1)

It appears that let-syntax is not creating a local scope, letting the 
binding for x escape into the surrounding scope.

Here is what R5RS has to say:

[section 5.2.2]
Definitions may occur at the beginning of a <body> (that is, the body of 
a lambda, let, let*, letrec, let-syntax, or letrec-syntax expression or 
that of a definition of an appropriate form). [...]
The variable defined by an internal definition is local to the <body>.


To me this pretty unambiguously requires the above example to return 1, 
not 2.

Have I missed something, or is this a bug in psyntax?


Matthias.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.