Summary
The body of a syntax definer should be allowed to be a macro call
Metadata
- Id: 4727021710170483adf246c2a62d2cdcab9cf427
- Trac id: 1306
- Type: defect
- Reporter: johnwcowan
- Owner:
- Cc:
- Status: closed
- Component: unknown
- Estimated difficulty:
- Resolution: invalid
- Priority: major
- Milestone: someday
- Version: 4.11.0
- Changetime: 2016-07-17 13:06:38 UTC
- Created: 2016-07-17 02:37:48 UTC
- Keywords:
Description
Currently Chicken doesn't support things like this:
(define (baz) 32)
(define-syntax foo
(syntax-rules ()
((foo) (syntax-rules () ((bar) (baz)))))))
(define-syntax quux (foo)) ; fails with "foo not defined"
On most Schemes that support macro varieties other than syntax-rules (and therefore extend R5RS in this situation), macro calls are expanded in this position, and `(quux)` evaluates to 32. However, on Chicken they aren't. They should be.
Changes and comments
[2016-07-17 13:06:38 UTC] sjamaan changed status from new to closed
[2016-07-17 13:06:38 UTC] sjamaan set resolution to invalid
[2016-07-17 13:06:38 UTC] sjamaan wrote:
I believe this to be incorrect: you are mixing phases. The definition of foo defines a macro that needs to be available when defining quux, which is syntax, so it needs to be defined in a higher/earlier phase (what's the correct term for this?) than quux.
This works when you wrap the definition of foo in a begin-for-syntax, or if you put it in a separate module and import it for syntax:
#!scm
(define (baz) 32)
(begin-for-syntax
(define-syntax foo
(syntax-rules ()
((foo) (syntax-rules () ((bar) (baz)))))))
(define-syntax quux (foo))
(print (quux)) ; prints 32