[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question about Presentations
Date: Sat, 13 Oct 90 19:35 EDT
From: RWK@fuji.ila.com (Robert W. Kerns)
The problem is your use of (FORMAT STREAM "~A" LABEL), if label
is not a string, creates a presentation, because FORMAT calls
WRITE in that case. This presentation will be a SYMBOL presentation,
and since SYMBOL is a subtype of EXPRESSION, it will satisfy your
call to ACCEPT. (When multiple presentations could apply, the system
always chooses the innermost).
Bob's explanation of the problem is correct, but there's a simpler
solution. DW:WITH-OUTPUT-AS-PRESENTATION accepts an option to control
whether the internal presentations can be selected:
:ALLOW-SENSITIVE-INFERIORS. This defaults to T, but if you specify NIL
then the internal presentations will be ignored by ACCEPT.
(defun present-as (object label &key (stream *standard-output*))
"Presents object to stream with given label"
(dw:with-output-as-presentation (:single-box t
:allow-sensitive-inferiors nil
:type (type-of object)
:stream stream
:object object)
(format stream "~a" label)))
I think this is what you were trying to accomplish with :SINGLE-BOX T.
There's one potential problem with this, though. The internal
presentations are completely ignored, so if you try to ACCEPT a type
that the label would satisfy but the object wouldn't, the label will
still be ignored. For example, if you use a symbol as the label when
you present your frame, and then do (accept 'symbol), you won't be able
to click on the label. Of course, Bob's solution has the same problem,
since the label's type is forgotten when it is converted to a string.
However, Bob's solution has a further problem that it won't work if
label is of a datatype that does not define a coercion to string (but
this can be fixed by changing (string label) to (format nil "~A"
label)).
barmar