From: ············@genworks.com
Subject: Re: writing out expressions prepended by #.
Date: 
Message-ID: <3AEB63E4.D26E2F6C@genworks.com>
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
From: Steve Long
Subject: Re: writing out expressions prepended by #.
Date: 
Message-ID: <3AF23E11.D3BFDE31@isomedia.com>
I really wish ICAD didn't clobbered defmethod either. My personal
preference is to use pure Lisp
(especially CLOS) over IDL whenever possible.  We deal with enormous
amounts of data and the difference between
loop and let-streams is significant.

Steve Long

············@genworks.com wrote:

> 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