[plt-scheme] Very basic macro question
Thanks very much. This has put me in the right direction!
From: jos.koot at telefonica.net
To: johnyseventy at hotmail.com; noelwelsh at gmail.com
CC: plt-scheme at list.cs.brown.edu
Subject: Re: [plt-scheme] Very basic macro question
Date: Tue, 19 Jan 2010 19:42:27 +0100
You probably want match. Alernatively you can use
syntax-case in a procedure for example:
#lang scheme
(define (trafo
x)
(syntax->datum
(syntax-case x ()
(id
(identifier? #'id) #'(identifier id))
((a ...) #'(list a
...))
(else #'else))))
(trafo 'a) ; --> (identifier a)
(trafo '(a b
c)) ; (list a b c)
(trafo "string") ; --> string
Jos
----- Original Message -----
From:
johny
seventy
To: noelwelsh at gmail.com
Cc: plt-scheme at list.cs.brown.edu
Sent: Tuesday, January 19, 2010 7:26
PM
Subject: RE: [plt-scheme] Very basic
macro question
> Date: Sun, 17 Jan 2010 18:42:32 +0000
> Subject: Re:
[plt-scheme] Very basic macro question
> From: noelwelsh at gmail.com
> To: johnyseventy at hotmail.com
>
CC: plt-scheme at list.cs.brown.edu
>
> On Sun, Jan 17, 2010 at 2:22 PM, johny seventy <johnyseventy at hotmail.com>
wrote:
> > I understand why example
> > four works but is
there anyway I can do this without eval?
>
> A transformer
binding and syntax-local-value.
>
> It doesn't make sense to
parameterise a macro by a run-time value --
> macros are expanded before
run-time so they cannot depend on run-time
> values.
>
>
N.
Thanks for the responses. I just want to clarify one more
thing.
I have an sexpr which is created dynamically at runtime and I
want to transform this sexpr. It seemed really easy to do the transformation
using a syntax-rules macro. So the problem is I have missed the boat at this
stage as macro expansion has already taken place. The only way I can see how
to invoke the macro at this stage is by using eval. I am not sure what you
mean by a transformer binding and syntax-local-value. Is there a simple
example of this in action I could take a look at?
Thanks for your
patience.
Not got a Hotmail account? Sign-up
now - Free
_________________________________________________
For
list-related administrative tasks:
http://list.cs.brown.edu/mailman/listinfo/plt-scheme
Se certificó que el correo entrante no contiene
virus.
Comprobada por AVG - www.avg.es
Versión: 9.0.730 / Base de datos
de virus: 270.14.150/2632 - Fecha de la versión: 01/19/10
08:34:00
_________________________________________________________________
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100119/96ee0d3d/attachment.html>