[racket] Macros, Eval and dynamic syntax?

From: Danny Yoo (dyoo at hashcollision.org)
Date: Wed Apr 17 15:17:25 EDT 2013

Let's say that we're given something like:

    (my-macro [(name:first-name type:string required:#t)
                      (name:last-name type:string)
                      (hash 'id middle-name 'type 'string)
                      (lambda () (do-something-arbitrary))])

Without thinking too much about implementation, what do you want the
phrase above to mean?

I'm assuming that you want the value of the above to be something like this:


    (list (hash 'name 'first-name 'type 'string 'required #t)
          (hash 'name 'last-name 'type 'string)
          (hash 'id middle-name 'type 'string)
          (lambda () do-something-arbitrary))

where the first three values in the resulting list are hashes, and the
fourth value is a lambda.  Is this the semantics you'd like, or are
you expecting something else?

If you are using eval in your macro, you may doing something that's
weird, because you're pushing computation to compile-time, and that's
usually not what you want to do here.

Posted on the users mailing list.