[mcclim-devel] DESCRIBE-OBJECT methods

rpgoldman at real-time.com rpgoldman at real-time.com
Thu Jun 2 03:17:48 UTC 2005


>>>>> "Mike" == Mike McDonald <mikemac at mikemac.com> writes:

    >> To: Andy Hefner <ahefner at gmail.com>
    >> Date: Wed, 1 Jun 2005 16:20:30 -0500
    >> From: rpgoldman at real-time.com

    >> Or is there a fatal shortsightedness somewhere? 

    Mike>   Circular lists?

Ah!  Good point!  I never use those, so I don't think carefully enough
about the possibility.  I was just worrying about chewing up too much
space on bona fide lists, and overlooked the circular list issue.
Would it be enough to use some breadcrumb method (e.g., a hash-table)
to handle this?  Also, is there some sort of glyph that would be an
obvious indicator to a user that we have reached a previously-visited
node?

One concern, of course, is that the breadcrumb trick will only fix
circular lists.  But recursive invocation of describe-object would
leave us open to circularities in graphs represented as lists, unless
we had a breadcrumb structure that was a dynamic variable, which seems
fairly unpleasant, something like:

(defvar *d-obj-breadcrumbs* nil)

(defmethod describe-object ((thing list) stream)
  (format stream "~S is a list~%" thing)
  (progv (*d-obj-breadcrumbs*) (or *d-obj-breadcrumbs*
                                  (make-hash-table :test #'eq))
     (loop for x in thing
           for i from 0
           until (and *print-length* (= i *print-length*))
	   if (gethash x *d-obj-breadcrumbs* nil)
	      do (format stream "<*>")
	   else 
              do (setf (gethash x *d-obj-breadcrumbs*) t)
	         (describe-object x stream)
	         (terpri stream)
	      ;; it would be nice if it were possible to select the
	      ;; ellipsis and make that cause description of further
	      ;; elements. [2005/06/01:rpg]
           finally (when (< (1+ i) (length thing))
		(format stream "...~%")))))

This still seems extremely kludgy, but I would love to see some
solution made to work: I hate to give up all hope of poking around
inside lists, though, and it sounds like the Do The Right Thing
alternative is not going to be with us for a long time.  In the
meantime, I figure it's at least up to me to provide attempts at a
solution for the list to shoot down, if only to prove that I'm serious
enough not to just sit around and whine about a missing feature!

Best,
R



More information about the mcclim-devel mailing list