[plt-scheme] macro-generating macros and the bizarre properties of syntax-local-get-shadower
On Mon, 14 May 2007, [ISO-8859-1] Jens Axel Søgaard wrote:
> Dimitris Vyzovitis skrev:
> > Can someone explain this:
> > (module bar mzscheme
> > (begin-for-syntax
> > (define (make-foos)
> > (let ((lst (generate-temporaries (list 'foo 'foocheck 'foov))))
> > (printf "temps:~a~n" (map syntax-object->datum lst))
> > lst)))
> >
> > (define-syntax (define-foo1 stx)
> > (syntax-case stx ()
> > ((_ val)
> > (let-values (((foo foocheck foov) (apply values (make-foos))))
> > (syntax-local-introduce
> > #`(begin (define-syntax #,foo val)
> > (define-syntax (#,foocheck stx)
> > (let ((#,foov (syntax-local-value (quote-syntax #,foo))))
> > (quasisyntax #,#,foov)))
> > (provide #,foo #,foocheck)))))))
>
> I got confused about all the unquote-syntax-es so there is a version
> without. Note that I'm only introducing marks on the
> generated indentifiers.
Well, the issue is the crash with no bindings at the meta-transformer
environment and how it goes away with syntax-local-get-shadower. Your
version is nice and clean, but it is not always appropriate. There are
cases where you really do need quasisyntax and unquotes; the purpose of
the rather contrived example was to demonstrate this mystery that baffled
me...
-- vyzo