[hunchentoot-devel] How to pass define-easy-handler symbol?

Jeffrey Cunningham jeffrey at cunningham.net
Sat Jan 13 22:22:14 UTC 2007


On Sat Jan 13, 2007 at 06:27:22PM +0100, Toby wrote:
> Jeffrey Cunningham wrote:
> > Now the macro sees only the symbol s, not the string it refers to. 
> > Is there a way to get around this?
> 
> Not without understanding how macros work.
> 
> May I suggest this book, especially chapter 8?
> http://www.gigamonkeys.com/book/
> 

Okay, I read chapter 8 (very good chapter). And I'm almost there. I
came up with this macro, which works:

(defmacro build-handler (category)
  (let ((symb (gensym)))
    `(progn 
      (setf ,symb (intern, category))
      (define-easy-handler (,symb :uri (catstr "/" ,category ".html") :default-request-type :post) ((arg))
        (declare (ignorable arg))
        (with-html (:html (:body (:h1 "Crazy as " (str ,category))))))))))

So 

(let ((s "batshit")) (build-handler s))

and 

(build-handler "batshit")

both work.

But they give the following warning:

-+  Warnings (2)
 |-- --> PROGN SETF 
 |   ==>
 |     (SETQ #:G0 (INTERN CL-USER::S))
 |   undefined variable: #:G0
 `-- This variable is undefined:
       #:G0

which doesn't seem healthy. 

Could you tell me what I'm doing wrong?

Regards,

--Jeff



More information about the Tbnl-devel mailing list