[plt-scheme] Macro rule selection

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Jan 30 16:59:33 EST 2009

On Jan 30, James Coglan wrote:
> > The minimalist (lazy?) person in me say you could use apply to
> > simplify it ;).
> 
> I just started learning Scheme and am also trying to implement it,
> so I'm just playing around with various features. I've been doing
> this for a couple weeks with SICP, haven't got to (apply). From what
> I gather, though, isn't (apply) just a way to call a function with
> arguments that are stored in a list? It's not a syntax for variable
> assignment, so wouldn't do what my (!)  and (square!) macros do. Is
> this correct? Or have I misunderstood what you're suggesting (this
> is quite likely)?

It is not possible to do your `!' syntax with any function.  You can
see this by the fact that two expressions that have the same value
will behave differently, for example:

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

vs

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

It makes such macros dangerous.

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


Posted on the users mailing list.