From: David J. Cooper <dcooper"	@genworks.com>=3AEB63E4.D26E2F6C%40genworks.com&number=2508	»b
Subject: Re: writing out expressions prepended by #.
Date: 
Message-ID: <988505023.167279@axilla.wwnet.net>
Dear Barry, Tim, and Kent,

Thank you for your replies. The defmethod of print-object is
what the doctor ordered. I couldn't define a new print-object
method for this point type itself, as doing so would have
affected the printing of points everywhere else in the
application (e.g. in object inspectors etc.)

So what I ended up doing was (the point type I am dealing
with supports accessors get-x, get-y, and get-z):

(defstruct icad-3d-point x y z)

(defun magic-point-expression (point)
  (make-icad-3d-point :x (get-x point)
		      :y (get-y point)
		      :z (get-z point)))

(cl:defmethod print-object ((point icad-3d-point) stream)
  (format stream "#.(make-point ~a ~a ~a)" 
	  (icad-3d-point-x point)
	  (icad-3d-point-y point)
	  (icad-3d-point-z point)))

(I had to specify the "cl" package with defmethod because
by default any package using the "icad-supported" package
sees the Flavors defmethod rather than the CLOS one).

Now I can write out a point-list readably with:

(pprint (mapcar #'magic-point-expression point-list))

 or simply

(print (mapcar #'magic-point-expression point-list))

There is of course some overhead involved in creating 
all those temporary structs when doing the output, but
for my usage this will not be an issue.

Thanks again,

 -dave