Summary
Syntax bound via let-syntax not bound in syntax-rules in its body
Metadata
- Id: daa3f09ffb9ad9e80822b75050d07c1b5a7e40e5
- Trac id: 1183
- Type: defect
- Reporter: syn
- Owner:
- Cc:
- Status: closed
- Component: expander
- Estimated difficulty:
- Resolution: wontfix
- Priority: minor
- Milestone: 4.11.0
- Version: 4.9.x
- Changetime: 2015-10-31 16:30:33 UTC
- Created: 2015-04-02 01:56:05 UTC
- Keywords:
Description
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.
Changes and comments
[2015-08-27 09:23:40 UTC] sjamaan changed milestone from someday to 4.11.0
[2015-08-27 09:23:40 UTC] sjamaan wrote:
I should take a closer look
[2015-10-31 16:30:33 UTC] sjamaan changed status from new to closed
[2015-10-31 16:30:33 UTC] sjamaan set resolution to wontfix
[2015-10-31 16:30:33 UTC] sjamaan wrote:
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 :)