[cl-who-devel] should cl-who::*html-mode* be a compile time flag?

Hi, The following code (defparameter *checked* nil) (with-html-output (#:out nil :prologue nil :indent nil) (:input :type "checkbox" :checked *checked*)) will get expanded to => (let ((#:out #:out)) (progn nil (write-string "<input type=\"checkbox\"" #:out) (let ((#:g2546 *checked*)) (cond ((null #:g2546)) ((and (eq #:g2546 t) (eq cl-who::*html-mode* :xml)) (progn (write-string " checked=\"checked\"" #:out))) ((and (eq #:g2546 t) (eq cl-who::*html-mode* :sgml)) (progn (write-string " checked" #:out))) (t (progn (write-string " checked=\"" #:out) (princ #:g2546 #:out) (write-string "\"" #:out))))) (write-string " />" #:out))) My question is, should the macro generate code based on the value of *html-mode* at compile/load time instead of runtime? If there are a lot of attributes the generated code will be bloated and I can't imagine a situation where you want to apply the same cl-who syntax tree with different *html-mode* at runtime. If there's a rational behind this I'd like to learn about it. Thanks, -- Mac

On Thu, 29 Mar 2007 11:14:04 -0700, "Mac Chan" <emailmac@gmail.com> wrote:
The following code
(defparameter *checked* nil)
(with-html-output (#:out nil :prologue nil :indent nil) (:input :type "checkbox" :checked *checked*))
will get expanded to
=>
(let ((#:out #:out)) (progn nil (write-string "<input type=\"checkbox\"" #:out) (let ((#:g2546 *checked*)) (cond ((null #:g2546)) ((and (eq #:g2546 t) (eq cl-who::*html-mode* :xml)) (progn (write-string " checked=\"checked\"" #:out))) ((and (eq #:g2546 t) (eq cl-who::*html-mode* :sgml)) (progn (write-string " checked" #:out))) (t (progn (write-string " checked=\"" #:out) (princ #:g2546 #:out) (write-string "\"" #:out))))) (write-string " />" #:out)))
My question is, should the macro generate code based on the value of *html-mode* at compile/load time instead of runtime?
If there are a lot of attributes the generated code will be bloated and I can't imagine a situation where you want to apply the same cl-who syntax tree with different *html-mode* at runtime.
If there's a rational behind this I'd like to learn about it.
I don't remember the details, but I guess this was just an oversight of Stefan when he sent the HTML-MODE patch in 2005. Feel free to send a patch to change this behaviour if you think it's worth it. Thanks, Edi.

On 3/30/07, Edi Weitz <edi@agharta.de> wrote:
I don't remember the details, but I guess this was just an oversight of Stefan when he sent the HTML-MODE patch in 2005. Feel free to send a patch to change this behaviour if you think it's worth it.
Sure, attached is a patch for this and also remove extra newlines if no prologue is specified. (I sometime log the generated html and the extra newline make the hunchentoot log very hard to read) Too bad http://common-lisp.net/~loliveira/ediware/ didn't track as far back as 2005. But in this case the change is trivial, otherwise the revision history will be very helpful. Thanks, -- Mac

On Fri, 30 Mar 2007 11:36:30 -0700, "Mac Chan" <emailmac@gmail.com> wrote:
Sure, attached is a patch for this and also remove extra newlines if no prologue is specified.
Thanks. I'm on my way to Cambridge for the ILC now, so I probably won't be able to update this before the end of next week.
But in this case the change is trivial, otherwise the revision history will be very helpful.
You could bug Pierre Thierry to add CL-WHO to his list: http://arcanes.fr.eu.org/~pierre/2007/02/weitz/ Cheers, Edi.

On Fri, 30 Mar 2007 11:36:30 -0700, "Mac Chan" <emailmac@gmail.com> wrote:
Sure, attached is a patch for this and also remove extra newlines if no prologue is specified.
Thanks. I've released a new version which incorporates your patches.
participants (2)
-
Edi Weitz
-
Mac Chan