Problems with html macro

Giannandrea Castaldi <[email protected]> Fri, 24 Sep 2004 18:07:20 +0200
Newsgroups gmane.lisp.open-source.franz
Message-ID <[email protected]>
Hi all,
I'm using htmlgen+aserve with cmucl 19a and have the following problem. 
I have added the following macro to have the generated html in a string:

(defmacro html-string (&rest html-sexps)
   `(let ((output-stream (make-string-output-stream)))
     (html-stream output-stream (html ,@html-sexps))
     (get-output-stream-string output-stream)))

and if I call it from the REPL I've no problem:

WIKI> (html-string ((:a :href (url-with-path "view.html" "HomePage")) 
(:princ "HomePage")))
"<a HREF=\"view.html?path=HomePage\">HomePage</a>"
WIKI>

But if I use this macro in a function as the following:

(defun path-link (word)
   (if (camel-case-path-p word)
       (if (exist-content word)
	  (html-string ((:a :href (url-with-path "view.html" word)) (:princ word)))
	  (html-string (:princ word) ((:a :href (url-with-path "view.html" 
word)) (:princ "?"))))
       word))

and do the following call:

WIKI> (path-link "HomePage")

have the following backtrace:

Error in KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER:  the function :PRINC is 
undefined.
    [Condition of type UNDEFINED-FUNCTION]

Restarts:
   0: [ABORT] Abort handling SLIME request.
   1: [ABORT] Return to Top-Level.

Backtrace:
   0: (KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER "<error finding name>" 
#.(SYSTEM:INT-SAP #x3FFFC1D8) #<Alien (* (ALIEN:STRUCT NIL # # # ...)) 
at #x3FFFBE70> (14))
   1: (KERNEL::INTERNAL-ERROR #.(SYSTEM:INT-SAP #x3FFFBE70) #<unused-arg>)
   2: ("call_into_lisp+#x8C [#x80546CC] /usr/local/bin/lisp")
   3: ("funcall2+#x23 [#x80544AE] /usr/local/bin/lisp")
   4: ("interrupt_internal_error+#xB3 [#x804FFD8] /usr/local/bin/lisp")
   5: ("sigtrap_handler+#x161 [#x805435E] /usr/local/bin/lisp")
   6: ("Foreign function call land")
   7: (PATH-LINK "HomePage")
       Locals:
         WORD = "HomePage"
       [No catch-tags]

The method path-link is defined in the file wiki.lisp that I've compiled 
and loaded with asdf using the following wiki.asd:

;;; -*- lisp -*-
(defpackage wiki-system
   (:use :common-lisp :asdf))

(in-package wiki-system)

;; (ext:without-package-locks (asdf:operate 'asdf:load-op :htmlgen))
;; (ext:without-package-locks (asdf:operate 'asdf:load-op :acl-compat))
(ext:without-package-locks (asdf:operate 'asdf:load-op :aserve))

(defsystem wiki
     :description "wiki: another wiki in common lisp."
     :long-description
     "Wiki is a wiki easy to use from people that don't know html"
     :version "0.1"
     :author "Giannandrea Castaldi <[email protected]>"
     :components
     ((:doc-file "README")
      (:file "packages")
      (:file "list" :depends-on ("packages"))
      (:file "wiki" :depends-on ("list"))
      (:file "publish" :depends-on ("wiki"))
      (:file "tests" :depends-on ("wiki"))
      (:file "list-tests" :depends-on ("list")))
     :depends-on (fiveam cl-ppcre))

I've loaded aserve manually because with cmucl 19a there are problems 
with the package lock.

Now, if I redefine manually the function path-link:

WIKI> (defun path-link (word)
   (if (camel-case-path-p word)
       (if (exist-content word)
	  (html-string ((:a :href (url-with-path "view.html" word)) (:princ word)))
	  (html-string (:princ word) ((:a :href (url-with-path "view.html" 
word)) (:princ "?"))))
       word))
PATH-LINK
WIKI>

It starts to work:

WIKI> (path-link "HomePage")
"HomePage<a HREF=\"view.html?path=HomePage\">?</a>"
WIKI>

Any idea about this behavior?

Thanks.

Giannandrea