[plt-scheme] Macro rule selection

From: James Coglan (jcoglan at googlemail.com)
Date: Fri Jan 30 17:35:49 EST 2009

> On Fri, Jan 30, 2009 at 3:44 PM, James Coglan <jcoglan at googlemail.com>
> wrote:
> > I just started learning Scheme and am also trying to implement it,
>
> In what language are you implementing it?


Ruby, code here: http://github.com/jcoglan/heist

I took the implict contract here to be the fn will always be a
> multiple-arity function; so you can leverage apply and it saves you
> one rule.


Taking this with Eli's examples:

 (let ([x 4])
   (! x (compose square add1))
   (list 'x= x))

vs

 (let ([x 4])
   (define foo (compose square add1))
   (! x foo)
   (list 'x= x))

I can see how this would be dangerous (like I said, I'm playing with
features rather than building rock-solid code right now). 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))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090130/41b6ecc5/attachment.html>

Posted on the users mailing list.