[plt-scheme] auxiliary macros

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Aug 3 10:18:33 EDT 2007

Hygiene is a uniformity default imposed on the expander with a  
provision for programmers to choose the non-default. I chose this  
word  carefully when I coined the phrase. So what you have *is* a  
hygienic solution. Congrats. -- Matthias






On Aug 3, 2007, at 8:35 AM, Vladimir Zlatanov wrote:

>  2. How can I use the macro system to eliminate the 'yield-name' part
> of the macro?
> One solution that works, but I do have a few problems with it.
> I had to break the hygiene, which in this case might not be that  
> bad, but it is not nice. More worringly for me, I'm not sure why  
> does it really work the way it works. It is a problem with my  
> understanding of macros, but that might pass with time =)
>
> What would be a hygienic solution?
>
> ===========================
> (require (lib "control.ss"))
>
> (define-syntax (make-gen stx)
>   (syntax-case stx ()
>     [(mkg (name arg ...) body ...)
>      (syntax-case (datum->syntax-object (syntax mkg) 'yield) ()
>        [yield (syntax
>                (define (name arg ...)
>                  (define (control-state) body ...)
>                  (define (yield value) (control resume-here (set!  
> control-state resume-here) value))
>                  (lambda () (prompt (control-state)))))])]))
>
> (make-gen (make-step)
>           (yield 1)
>           (yield 2)
>           (yield 3)
>           'finished)
>
> (define step (make-step))
>
> (step)(step)(step)(step)(step)
>
> ===========================
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.