This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Making 'write' use my own way of presenting defined classes


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?

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))                  
                                         )
  )
where indexed->string is my own function, but 'write' still outputs
in the customary 
  indexed@97289f89
manner, opaque to people wanting to view its fields.

Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]