This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Making 'write' use my own way of presenting defined classes
- From: Per Bothner <per at bothner dot com>
- To: Jocelyn Paine <popx at ifs dot org dot uk>
- Cc: kawa at sources dot redhat dot com
- Date: Sun, 14 Jul 2002 21:54:23 -0700
- Subject: Re: Making 'write' use my own way of presenting defined classes
- References: <Pine.LNX.4.21.0207130626150.24363-100000@pop3.ifs.org.uk>
Jocelyn Paine wrote:
If I define a new class with define-class or define-simple-class (I
usually do the latter, for efficiency), can I make the built-in output
functions such as 'write' and 'format' call my own function for converting
instances of the class to a string?
Yes.
I tried this by defining a toString method in one of my classes:
(define-simple-class <indexed-name> () (attr <symbol>)
(indices <list>)
((toString) :: <java.lang.String>
(indexed->string (this))
This should work - I can't off-hand think of why it might not.
Look at the generated .class file, using javap or gnu.bytecode.dump,
to see if there is something funny about the toString method or its
parameters or attributes.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/