[racket] Macro using eval inside html-template

From: Philipp Dikmann (philipp at dikmann.de)
Date: Mon Jan 7 15:57:42 EST 2013

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


Posted on the users mailing list.