[plt-scheme] full-expanded syntax and internal definitions
Dave Herman skrev:
>> No, so there no local macro definitions in fully expanded code.
>
> If that's true then this must mean that local-expand is not guaranteed
> to produce fully-expanded code?
Yes.
> > (define-syntax (quote-expand stx)
> (syntax-case stx ()
> [(_ e)
> (with-syntax ([exp (local-expand #'e 'expression '())])
> #'(quote exp))]))
> > (quote-expand (lambda ()
> (define-syntax foo (syntax-rules () [(_) 42]))
> (define y 10)
> y))
> (lambda () (letrec-syntaxes+values (((foo) (syntax-rules () ((_) 42))))
> (((y) (#%datum . 10))) y))
Compare this with the output expand which "expands all non-primitive
syntax":
> (syntax-object->datum
(expand #'(lambda ()
(define-syntax foo (syntax-rules () [(_) 42]))
(define y 10)
y)))
(lambda () (letrec-values (((y) (#%datum . 10))) y))
/Jens Axel