[plt-scheme] Very basic macro question

From: Jos Koot (jos.koot at telefonica.net)
Date: Tue Jan 19 13:42:27 EST 2010

You probably want match. Alernatively you can use syntax-case in a procedure for example:

#lang scheme
(define (trafo x)
  (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

  ----- 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:


  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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100119/53ebe2a9/attachment.html>

Posted on the users mailing list.