[CM] A question about def-clm-struct

cristopher pierson ewing cewing@u.washington.edu
Wed, 4 Dec 2002 10:01:13 -0800 (PST)


Thanks,  that's sort of what I had figured.  I didn't think of defining my
own macro to print though.  The reason being that I wanted something that
would work whenever I typed the name of the struct, without having to ask
it to print a special way.  So if I had created a struct like so:

> (setf joe (make-foo))

I would qutomatically see foo printed the way I wanted to see it.  And if
I entered

> foo

at any time, the listener would return the printed representation of foo
that I wanted to see, rather than the generic representation used for all

I understand the bit about the struct needing to be compatible with C
structs, but would there be a way to piggy-back this functionality on the
def-clm-struct macro such that LISP-related functionality could be
maintained, but not passed on to the C side of things?

I'm going to dig around in the source a bit to see if I can come to a
better understanding of how the whole FFI thing works.  Where exactly can
I find the definition of 'def-clm-struct'?

Thanks again for the answer.


Cris Ewing
CARTAH Assistant
University of Washington
Home Phone: (206) 365-3413
E-mail: cewing@u.washington.edu

On Wed, 4 Dec 2002, Bill Schottstaedt wrote:

> > Does def-clm-struct also allow the types of defstruct options that are
> > allowed by defstruct?
> No -- sorry; each such option requires Lisp->C translation support.
> Currently in CL def-clm-struct piggybacks on the existing array
> support.  To add specialized print functions, it needs to register a
> new type for the struct, then add an entry to mus_print_object.  You
> could get the same effect by defining a macro that does the printing
> you want (but, of course, a value like 'baz isn't going to work -- I
> don't try to support symbols in any version of the run macro).
> (def-clm-struct foo (bar 1.0))
> (defmacro print-foo (f) `(clm-print "<hello: ~A>" (foo-bar ,f)))