[plt-scheme] Macro rule selection

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Jan 30 18:26:19 EST 2009

On Jan 30, James Coglan wrote:
> 
> [...] Maybe a better idea is:
> 
> (define-syntax ! (syntax-rules ()
>   [(! x fn arg ...)
>     (set! x (fn x arg ...))]))
> 
> Then you wouldn't get into trouble trying to do this:
> 
> (! x (compose square add1))

And now, if you only use boxes (like most compilers do for you for any
binding that can be modified), then you won't even need a macro:

  (define (! x fn . args)
    (set-box! x (apply fn x args)))

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.