[plt-scheme] side effects in R6RS modules

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Sun May 3 10:53:21 EDT 2009

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))))))



Posted on the users mailing list.