2011/5/21 Matthew Koichi Grimes <mkg@cs.nyu.edu>
I have a few questions about custom types in Gambit. I apologize if they seem elementary, but I couldn't find an answer in the docs or the mailing list archives, and I'm new to Scheme.

I've defined a new type "my-type" using define-type. How can I control how an instance of my-type gets displayed in the REPL? I know I can declare individual slots of my-type to be unprintable:, but I'd like to just be able to define a "print-my-type" function that gets called.

Why would you want this? Anyhow, you could make your own Gambit patch that adds a pp: procedure argument to define-type. Feel free to publish your patch on the Dumping grounds.
 
Similarly, how can I define a custom constructor that does something more complicated than assign arguments to slots?

By defining your own procedure that does the job.
 
Finally, there seem to be four options for defining structs in Gambit: define-structure, define-type, srfi-9's define-record-type, and meroon. Which should I be using? At the moment, I'm only defining very basic structures (e.g. doubly-linked lists), but my ambitions will probably grow.

Depends on your specific needs. I suppose define-type is more optimized than meroon.

Someone else please verify that Gambit's define-record-type is just an alternative name for define-type, just like what call/cc is to call-with-current-continuation .
 
Best,
-- Matt


_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list