Nested calls to WITH-OUTPUT-AS-PRESENTATION

Paolo Amoroso <[email protected]> Fri, 26 Dec 2003 22:18:06 +0100
Newsgroups gmane.lisp.clim
Organization Paolo Amoroso - Milano, ITALY
Message-ID <[email protected]>
Part II of the LUV 93 CLIM tutorial includes a simple CLOS class
browser in file `class-browser.lisp'. The same example is included in
section 14.4 "Example of incremental redisplay in CLIM" of Franz's
"CLIM 2 User Guide" (version 2.2).

The application defines a browser node class to keep track of
displayed nodes:

;; OBJECT is the Lisp object associated with the node (i.e., a class object)
;; INFERIORS is a list of child nodes
;; SUPERIORS is a list of parent nodes
;; TICK is incremented whenever this node should be redisplayed
(defclass class-browser-node ()
    ((object :reader node-object :initarg :object)
     (inferiors :accessor node-inferiors :initform nil)
     (superiors :accessor node-superiors :initform nil)
     (tick :accessor node-tick :initform 0)))

It later defines a presentation, and ACCEPT/PRESENT methods, for class
objects:

;;; The CLASS presentation type

(clim:define-presentation-type class-name ()
  :history t)

The method for displaying nodes then looks like:

;; Note the use of NODE-TICK as the redisplay cache value
(defmethod display-node ((node class-browser-node) stream)
  (clim:updating-output (stream :unique-id node
				:cache-value (node-tick node))
    (let ((class (node-object node)))
      (clim:with-output-as-presentation (stream node 'class-browser-node)
        (clim:with-output-as-presentation (stream class 'class-name)
          (write (node-object-name node) :stream stream))))))

Why does it include the two nested calls to
WITH-OUTPUT-AS-PRESENTATION? Given that the application defines
commands and presentation to command translators involving
CLASS-BROWSER-NODE, wouldn't it suffice for DISPLAY-NODE to include
only the first call to WITH-OUTPUT-AS-PRESENTATION? What is the
purpose of the nested calls?


Paolo
-- 
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
--
[To unsubscribe to this list send an email to "[email protected]"
with the following text in the BODY of the message "unsubscribe clim"]