Hi all:
I do have a strange behaviour of a small code snippet ...: (the used macro with-html-output is from CL-WHO - see http:// www.weitz.de/cl-who - it generates HTML markup)
(defmacro as-html (&body body) `(with-html-output (*standard-output*) ,@body))
(defmodel simple (family) ((slot-1 :accessor slot-1 :initform (c-in nil) :initarg :slot-1)) (:default-initargs :value (c? (as-html (:h1 (^slot-1))))))
Now when inspecting the result of
(make-instance 'simple :slot-1 "Hi")
I get no value back for slot-1 but simply see
<h1></h1>
... - what the f*ck am I doing wrong ???
Inspecting the instance reveals:
SIMPLE15 is a standard-object. [type: SIMPLE] -------------------- Class: #<STANDARD-CLASS SIMPLE> .MD-STATE: :AWAKE .AWAKEN-ON-INIT-P: NIL .CELLS: ((.KIDS . =0/.KIDS/SIMPLE15])) .CELLS-FLUSHED: ((.VALUE . <vld>=1/.VALUE/SIMPLE15])) ADOPT-CT: 0 .MD-NAME: SIMPLE15 .FM-PARENT: NIL .VALUE: "</h1>" ZDBG: NIL .KID-SLOTS: NIL .KIDS: NIL SLOT-1: "Hallo"
Hunh? Slot ".value" is "</h1>" ??
Any help really appreciated ...
Oh - ah - this is going to be part of marrying Cells with Edi Weitz's Hunchentoot Web Server (see http://www.weitz.de/hunchentoot )
Thx!!!
Cheers -
Frank
Am 13.05.2007 um 01:21 schrieb Frank Goenninger:
SIMPLE15 is a standard-object. [type: SIMPLE]
Class: #<STANDARD-CLASS SIMPLE> .MD-STATE: :AWAKE .AWAKEN-ON-INIT-P: NIL .CELLS: ((.KIDS . =0/.KIDS/SIMPLE15])) .CELLS-FLUSHED: ((.VALUE . <vld>=1/.VALUE/SIMPLE15])) ADOPT-CT: 0 .MD-NAME: SIMPLE15 .FM-PARENT: NIL .VALUE: "</h1>" ZDBG: NIL .KID-SLOTS: NIL .KIDS: NIL SLOT-1: "Hallo" <----
Actually, this is
SLOT-1: "Hi! ;-) Copy/Paste error ... Oh well ...
I have been digging a little deeper - and only can think of some strange thing happening with "<" and ">" being interpreted by Cells ??? Being desperate ...
Frank
Frank Goenninger wrote:
Hi all:
I do have a strange behaviour of a small code snippet ...: (the used macro with-html-output is from CL-WHO - see http://www.weitz.de/cl-who - it generates HTML markup)
(defmacro as-html (&body body) `(with-html-output (*standard-output*) ,@body))
(defmodel simple (family) ((slot-1 :accessor slot-1 :initform (c-in nil) :initarg :slot-1)) (:default-initargs :value (c? (as-html (:h1 (^slot-1))))))
Now when inspecting the result of
(make-instance 'simple :slot-1 "Hi")
I get no value back for slot-1 but simply see
<h1></h1>
... - what the f*ck am I doing wrong ???
Inspecting the instance reveals:
SIMPLE15 is a standard-object. [type: SIMPLE]
Class: #<STANDARD-CLASS SIMPLE> .MD-STATE: :AWAKE .AWAKEN-ON-INIT-P: NIL .CELLS: ((.KIDS . =0/.KIDS/SIMPLE15])) .CELLS-FLUSHED: ((.VALUE . <vld>=1/.VALUE/SIMPLE15])) ADOPT-CT: 0 .MD-NAME: SIMPLE15 .FM-PARENT: NIL .VALUE: "</h1>" ZDBG: NIL .KID-SLOTS: NIL .KIDS: NIL SLOT-1: "Hallo"
Hunh? Slot ".value" is "</h1>" ??
Any help really appreciated ...
The first problem was writing the html to standard output instead of a string, the second problem is that cl-who does not quite work the way you think. What I did was replace as-html with the appropriate with-html-output form and then macroexpand. Give it a try. Meanwhile, this works:
(defpackage #:whofix (:use #:common-lisp #:cells #:cl-who))
(in-package :whofix)
(defmacro as-html (var &body body) `(with-output-to-string (,var) (with-html-output (,var) ,@body) ))
(defmodel simple (family) ((slot-1 :accessor slot-1 :initform (c-in nil) :initarg :slot-1)) (:default-initargs :value (c? (trc "enetering rule" (^slot-1)) (as-html xxx (:h1 (write-string (^slot-1) xxx))))))
(describe (make-instance 'simple :slot-1 "booters"))
;;;0> 4331 enetering rule "booters" ;;;SIMPLE8054 is an instance of #<STANDARD-CLASS SIMPLE>: ;;; The following slots have :INSTANCE allocation: ;;; .MD-STATE :AWAKE ;;; .AWAKEN-ON-INIT-P NIL ;;; .CELLS ((.KIDS . =0/.KIDS/SIMPLE8054])) ;;; .CELLS-FLUSHED ((.VALUE . <vld>=10966/.VALUE/SIMPLE8054])) ;;; ADOPT-CT 0 ;;; .MD-NAME SIMPLE8054 ;;; .FM-PARENT NIL ;;; .VALUE " ;;; ;;;<h1>booters</h1>" ;;; ZDBG NIL ;;; .KID-SLOTS NIL ;;; .KIDS NIL ;;; SLOT-1 "booters"
Hi Kenny -
Am 13.05.2007 um 03:51 schrieb Ken Tilton:
The first problem was writing the html to standard output instead of a string, the second problem is that cl-who does not quite work the way you think. What I did was replace as-html with the appropriate with-html-output form and then macroexpand.
Hm - ok - now that you say it ... Obviously the right thing to do. I was looking for Cells misuse anywhere - wrong. It was the CL-WHO side which I did not get right. Oh well....
Give it a try. Meanwhile, this works:
(defpackage #:whofix (:use #:common-lisp #:cells #:cl-who))
(in-package :whofix)
(defmacro as-html (var &body body) `(with-output-to-string (,var) (with-html-output (,var) ,@body) ))
As this is working as-html has to be changed because in CL-WHO there's
(defmacro with-html-output-to-string ((var &optional string-form &key (element-type ''character) prologue indent) &body body) "Transform the enclosed BODY consisting of HTML as s-expressions into Lisp code which creates the corresponding HTML as a string." `(with-output-to-string (,var ,string-form #-(or :ecl :cmu :sbcl) :element-type #-(or :ecl :cmu :sbcl) ,element-type) (with-html-output (,var nil :prologue ,prologue :indent ,indent) ,@body)))
So, we can write:
(defmacro as-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue nil) ,@body))
Hm - coming back to your remark
the second problem is that cl-who does not quite work the way you think
Well, I think I have understood that I have to output any data via write-string because this is what is to be inserted between tags... Anything else?
Thx anyway!
Frank
Frank Goenninger wrote:
Hi Kenny -
Am 13.05.2007 um 03:51 schrieb Ken Tilton:
The first problem was writing the html to standard output instead of a string, the second problem is that cl-who does not quite work the way you think. What I did was replace as-html with the appropriate with-html-output form and then macroexpand.
Hm - ok - now that you say it ... Obviously the right thing to do. I was looking for Cells misuse anywhere - wrong. It was the CL-WHO side which I did not get right. Oh well....
Give it a try. Meanwhile, this works:
(defpackage #:whofix (:use #:common-lisp #:cells #:cl-who))
(in-package :whofix)
(defmacro as-html (var &body body) `(with-output-to-string (,var) (with-html-output (,var) ,@body) ))
As this is working as-html has to be changed because in CL-WHO there's
(defmacro with-html-output-to-string ((var &optional string-form &key (element-type ''character) prologue indent) &body body) "Transform the enclosed BODY consisting of HTML as s-expressions into Lisp code which creates the corresponding HTML as a string." `(with-output-to-string (,var ,string-form #-(or :ecl :cmu :sbcl) :element-type #-(or :ecl :cmu :sbcl) ,element-type) (with-html-output (,var nil :prologue ,prologue :indent ,indent) ,@body)))
So, we can write:
(defmacro as-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue nil) ,@body))
Hm - coming back to your remark
the second problem is that cl-who does not quite work the way you think
Well, I think I have understood that I have to output any data via write-string because this is what is to be inserted between tags... Anything else?
I actually have never used cl-who before, so I cannot help you on that last bit. I saw disappearing characters and guessed "stream issue", then macroexpanded the w-h-o call to see why I was still just getting hl-\hl.
kt