[racket] unhygienic macro on purpose?

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Tue Aug 3 09:14:19 EDT 2010

Huh? The one in the teaching languages doesn't provide (functional)
mutators, right? So I was trying to write (define-struct-with-setters
...) that would. Students could require this file and use the
define-struct-with-setters. So they'd be requiring it from a student
language, but the macro is written in #lang racket.

Oh, wait. I think I understand. I should find where define-struct is
defined for the student languages and use that. I'll see if I can find
that.

Thanks,
Todd

On Tue, Aug 3, 2010 at 8:07 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Why not just use the one from the teaching language instead of breaking hygiene?
>
> Robby
>
> On Tue, Aug 3, 2010 at 7:02 AM, Todd O'Bryan <toddobryan at gmail.com> wrote:
>> 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
>>
>


Posted on the users mailing list.