(defmethod describe-object ((integer-line yawn-war::integer-line)
stream)
(cl-who:with-html-output
((:ul)
(loop for class-slot in (sb-mop:class-slots (class-of integer-
line))
for name = (sb-mop:slot-definition-name class-slot)
for val = (slot-value integer-line name)
do
(cl-who:htm
((:li)
(cl-who:fmt "~s" name) ":=" (cl-who:fmt "~s" val)))))))
run (describe o) and if o is a integer-line print with html else do
the standard describe. Works like a charm.
However, I would like to extend this definition to a list of objects
(defparameter *describe-object-as-html* '(yawn-war::integer-line other-
object))
i.e. if the object is in *describe-object-as-html* describe object
with html tags, else just use normal describe.
If there were some next-method something like this could work:
(defmethod describe-object ((object t) stream)
(if (member object *describe-object-as-html*)
"do with html tags"
(next-method) ;; else just use plain old standard describe
))
any hints?
thanx
olivier buecel
> I have specified describe-object to some object type to describe the
> object in some html-fied manner
[...]
> i.e. if the object is in *describe-object-as-html* describe object
> with html tags, else just use normal describe.
Roll up your own html-printing generic function, defaulting on
html-escaped PRINT-OBJECT when necessary. Mixing plain text output of
default PRINT-OBJECT specializations with HTML-spitting methods doesn't
seem that robust.
--
You only have power over people so long as you don’t take everything
away from them. But when you’ve robbed a man of everything he’s no longer
in your power — he’s free again. -- Aleksandr Isayevich Solzhenitsyn
> I have specified describe-object to some object type to describe the
> object in some html-fied manner
...
> However, I would like to extend this definition to a list of objects
> (defparameter *describe-object-as-html* '(yawn-war::integer-line other-
> object))
> i.e. if the object is in *describe-object-as-html* describe object
> with html tags, else just use normal describe.
> If there were some next-method something like this could work:
> (defmethod describe-object ((object t) stream)
> (if (member object *describe-object-as-html*)
> "do with html tags"
> (next-method) ;; else just use plain old standard describe
> ))
Well, there is CALL-NEXT-METHOD, but that won't work if you end up
redefining the method on the topmost object T. There isn't any next
method because you've replaced it.
There are a couple of potential solutions:
(1) Use an :AROUND method on DESCRIBE-OBJECT which can then choose to
CALL-NEXT-METHOD or not.
(2) [Better]. Write your own printing method and specialize it as
desired for various types. Of course, this means that you would
have to handle printing of CONS, VECTOR, etc. yourself, but that
does give you the most control. And it also isolates you from
interference with other code.
--
Thomas A. Russ, USC/Information Sciences Institute
thanx
olivier buechel