[plt-scheme] Macro is misbehaving...

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Mon Jun 12 21:47:08 EDT 2006

On 12/06/06, Ryan Culpepper <ryan_sml at yahoo.com> wrote:
> Okay, I'm starting to see the problem.
> You want to distinguish between two cases:
> 1) If "s" *evaluates to*  a symbol, then return the symbol
> 2) If "s" *has the syntactic form* (method arg ...), then call the
> method
> You are mixing static and dynamic criteria. Instead, why don't you
> rewrite the first case as:
> 1) If "s" has the syntactic form of just the identifier "next"
> Then you can write the macro like this:
> (define-syntax slide/foo
>   (syntax-rules (next)
>     [(slide/foo obj next)
>      'next]
>     [(slide/foo obj (method arg ...))
>      (send obj method arg ...)]))
> (I'll let you generalize it to multiple things after the "obj".)
> > Still, can't understand your explanation on why this doesn't work.
> > next should never be evaluated. Afterall (quote next) is exactly
> > not to evaluate next.
> Only if "(quote next)" is used as an expression. In the code your
> macro produced, it wasn't.
> Ryan

Humm, yes, it makes sense now. Thanks for the help.

Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering

Posted on the users mailing list.