6.10 Object Printing (original) (raw)

6.10 Object Printing🔗

To customize the way that a class instance is printed byprint, write and display, implement theprintable<%> interface.

The printable<%> interface includes only thecustom-print, custom-write, andcustom-display methods. The custom-print method accepts two arguments: the destination port and the currentquasiquote depth as an exact nonnegative integer. Thecustom-write and custom-display methods each accepts a single argument, which is the destination port to write ordisplay the object.

Calls to the custom-print, custom-write, orcustom-display methods are like calls to a procedure attached to a structure type through the prop:custom-writeproperty. In particular, recursive printing can trigger an escape from the call.

See prop:custom-write for more information. Theprintable<%> interface is implemented withinterface* and prop:custom-write.

Like printable<%>, but includes only thecustom-write and custom-display methods. A print request is directed to custom-write.