[plt-scheme] side effects in R6RS modules
At Sun, 03 May 2009 08:53:21 -0600, Chongkai Zhu wrote:
> Michele Simionato wrote:
> > (define-syntax define+
> > (lambda (x)
> > (syntax-case x ()
> > ((define+ name value)
> > #'(begin
> > ;; dirty trick to get an expand time side effect
> > (define-syntax dummy (begin (register #'name) (lambda (x) #f)))
> > ;; the real definition
> > (define name value))))))
> >
>
> Why the dirty trick? This works:
>
> (define-syntax define+
> (lambda (x)
> (syntax-case x ()
> ((define+ name value)
> (begin (register #'name)
> #'(define name value))))))
No, this does not work. The reasons is explained in the "Composable and
Compilable Macros" paper that Michele cited.