[plt-scheme] Struct Printer
Hello,
Jens Axel Søgaard <jensaxel at soegaard.net> writes:
> You could alter the current printer.
Yeah, that's what I'm doing now:
http://www.theworld.com/~proteus/print-dispatch.scm
This is fast because the print-dispatch function extracts the
struct-type from a given object and does a lookup in the 'eq?' based
hash table.
Unfortunately, the ability to get the struct-type requires a
sufficiently senior inspector and I'd like this to also work with
opaque structs. I have another version with a table that is an alist
mapping predicates to printers. Of course, this is slow because the
print-dispatch function may have to search the whole list for a
matching predicate...
I really wish Scheme had a type-of function.
Some days Common Lisp looks very pretty. :-/
Ed