[racket] Macro using eval inside html-template

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Jan 7 17:20:55 EST 2013

I don't see any need for a macro here. Why not use a function that iterates over these 'forms': 

(define (expr-iter . form)
  (for ((f form))
    (case (first f) 
      ... 
      [(math) (eval (second f) some-useful-namespace)]
      ...)))





On Jan 7, 2013, at 3:57 PM, Philipp Dikmann wrote:

> Hello Racket-Users,
> 
> in trying to iterate a series of expressions and evaluating them differently on a case-by-case basis - specifically in the body of a (html-template) - Racket is throwing errors indicating that my expressions end up in the wrong places. In the code below, it appears that + is being interpreted as an HTML element name; am I messing up expansion time and run time?
> 
> 
> #lang racket
> 
> (require (planet neil/html-template:2:2))
> 
> (define-syntax-rule (expr-iter form ...)
>  (begin
>    (case (car 'form)
>      [(title) (display (cadr 'form))]
>      [(math) (eval (cadr 'form))]
>      [(html) (html-template
>               (eval (cadr 'form)))]) ...))
> 
> (expr-iter (title "sometitle")
>           (math (+ 1 2))
>           (html (p "hello")))
> 
> 
> Best regards,
> Philipp
> 
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20130107/38ccef5b/attachment.p7s>

Posted on the users mailing list.