One thing that's made the built-in describe less useful for me than it might be is that it seems to bottom out at CONSes. So if I have data structures that contain a CONS (e.g., a list-valued slot), I get tantalizingly close to seeing what I want to see, but then can't drill down any further. [I suppose I could try invoking Clouseau...]
I believe it would be relatively straightforward to add a new describe-object method that would look at the contents of a CONS, but I'm concerned that this might be risky in the case of objects that are very large. PPRINT, of course, gets around this by using *print-length*, and I suppose I could also, but that seems like an abuse of a built in. For lack of a better, here's what I came up with (inserted into DESCRIBE.LISP):
(defmethod describe-object ((thing list) stream) (format stream "~S is a list~%" thing) (loop for x in thing for i from 0 until (and *print-length* (= i *print-length*)) do (describe-object x stream) (terpri stream) finally (when (< (1+ i) (length thing)) (format stream "...~%"))))
I don't think that the above is really right, but perhaps it's a step in the right direction? Can anyone refine it?
Also, when I was editing describe.lisp, it confused my emacs interface a bunch, because the mode line lists specifies COMMON-LISP as the package, but the in-package form says CLIM-LISP. The Allegro Emacs-lisp interface ignores the latter in favor of the former!
Best, R
I think the underlying issue is that conses are printed via the lisp printer, and it does not know to output the objects as presentations so that you can invoke describe and/or the inspector on the individual elements. The master plan (if there is one) involves writing a portable replacement for the pretty printer that is aware of presentations. I believe Gilbert Baumann has done a substantial portion of this work, but the effort has stalled as he is busy elsewhere.
An alternate stopgap measure would be a presentation method for lists which presents each element of the list contents itself rather than relying on the lisp printer. Then you get roped into reimplementing the formatting and printer controls yourself..
On 6/1/05, rpgoldman@real-time.com rpgoldman@real-time.com wrote:
One thing that's made the built-in describe less useful for me than it might be is that it seems to bottom out at CONSes. So if I have data structures that contain a CONS (e.g., a list-valued slot), I get tantalizingly close to seeing what I want to see, but then can't drill down any further. [I suppose I could try invoking Clouseau...]
I believe it would be relatively straightforward to add a new describe-object method that would look at the contents of a CONS, but I'm concerned that this might be risky in the case of objects that are very large. PPRINT, of course, gets around this by using *print-length*, and I suppose I could also, but that seems like an abuse of a built in. For lack of a better, here's what I came up with (inserted into DESCRIBE.LISP):
(defmethod describe-object ((thing list) stream) (format stream "~S is a list~%" thing) (loop for x in thing for i from 0 until (and *print-length* (= i *print-length*)) do (describe-object x stream) (terpri stream) finally (when (< (1+ i) (length thing)) (format stream "...~%"))))
I don't think that the above is really right, but perhaps it's a step in the right direction? Can anyone refine it?
Also, when I was editing describe.lisp, it confused my emacs interface a bunch, because the mode line lists specifies COMMON-LISP as the package, but the in-package form says CLIM-LISP. The Allegro Emacs-lisp interface ignores the latter in favor of the former!
Best, R _______________________________________________ mcclim-devel mailing list mcclim-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/mcclim-devel
"AH" == Andy Hefner ahefner@gmail.com writes:
AH> I think the underlying issue is that conses are printed via the lisp AH> printer, and it does not know to output the objects as presentations AH> so that you can invoke describe and/or the inspector on the individual AH> elements. The master plan (if there is one) involves writing a AH> portable replacement for the pretty printer that is aware of AH> presentations. I believe Gilbert Baumann has done a substantial AH> portion of this work, but the effort has stalled as he is busy AH> elsewhere.
AH> An alternate stopgap measure would be a presentation method for lists AH> which presents each element of the list contents itself rather than AH> relying on the lisp printer. Then you get roped into reimplementing AH> the formatting and printer controls yourself..
Yes, my describe-object for lists was intended to provide such a stopgap. Is it an acceptable stopgap? I realize that the formatting is pretty crummy (e.g., nested lists aren't indented, etc.), but do you think it could be extended? Any particular direction to go? Or is there a fatal shortsightedness somewhere? Suggestions for things that would make this more useful?
Thanks, R
To: Andy Hefner ahefner@gmail.com Date: Wed, 1 Jun 2005 16:20:30 -0500 From: rpgoldman@real-time.com
Or is there a fatal shortsightedness somewhere?
Circular lists?
Mike McDonald mikemac@mikemac.com
"Mike" == Mike McDonald mikemac@mikemac.com writes:
>> To: Andy Hefner ahefner@gmail.com >> Date: Wed, 1 Jun 2005 16:20:30 -0500 >> From: rpgoldman@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