I'm trying to write a macro to provide functional mutators for the
teaching languages. Here's the main construct:

(define-syntax (define-struct-with-setters stx)
  (syntax-case stx ()
    [(_ id fields)
     (let ([field-names (syntax->list #'fields)])
       #`(begin
           (define-struct id fields #:transparent)
           #,@(for/list ([f field-names])
              (setter #'id field-names f))))]))

Everything works, mostly. The problem is that this uses define-struct
from #lang racket instead of the teaching language where the macro is
invoked. (Thus, the #:transparent argument.) I know there's some way
to get define-struct evaluated in the environment of the macro's use
instead of its definition, but I can't get it to work.

Is there a way to fix it?

Thanks,
Todd
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to