[gambit-list] questions about define-type, and structures in general

Mikael mikael.rcv at gmail.com
Sun May 22 06:39:05 EDT 2011

2011/5/21 Matthew Koichi Grimes <mkg at 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

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 at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20110522/2ee18e40/attachment.htm>

More information about the Gambit-list mailing list