Opened 9 years ago

Closed 9 years ago

#1183 closed defect (wontfix)

Syntax bound via let-syntax not bound in syntax-rules in its body

Reported by: Moritz Heidkamp Owned by:
Priority: minor Milestone: 4.11.0
Component: expander Version: 4.9.x
Keywords: Cc:
Estimated difficulty:


I'm not entirely sure whether this use of let-syntax is valid:

(define-syntax foo
  (let-syntax ((bar (syntax-rules ()
                      ((_ x) '(x x)))))
    (syntax-rules ()
      ((_ x) (bar x)))))

(foo 1)

;; Error: unbound variable: bar

Intuitively it makes sense but the report doesn't seem to say anything about the semantics of this use and at least Guile and Chibi signal the same error.

Change History (2)

comment:1 Changed 9 years ago by sjamaan

Milestone: someday4.11.0

I should take a closer look

comment:2 Changed 9 years ago by sjamaan

Resolution: wontfix
Status: newclosed

This would require that macros close over their local macro environment, which is much trickier than it sounds. In CHICKEN, macros are not handled as closures, but as a "relatively" simple renaming mechanism.

It looks like Chibi and Guile don't work like that either, nor do Gauche, Scheme48 or even Racket with its fancy syntax objects. MIT Scheme doesn't grok it at all; it gets confused about the definition even: "Syntactic binding value must be a keyword: foo"

I agree adding this would be Very Cool, but on the other hand, it's probably not worth the effort (and resulting explosion of bugs): it requires hacking this into the compiler and the interpreter, I think. Plus, it wouldn't buy us much because portable code can't rely on it anyway, and probably not many people will need this feature. We have enough other brokenness to worry about :)

Note: See TracTickets for help on using tickets.