8.16.0.1
8.1 Custom Write Implementations
(require rebellion/custom-write) | package: rebellion |
A custom write implementation is a function that prints values and is suitable for use with prop:custom-write. Custom write implementations must satisfy the custom-write-function/c contract.
value
= (-> any/c output-port? custom-write-mode/c void?)
A contract describing functions suitable for use with prop:custom-write.
value
custom-write-mode/c : flat-contract? = (or/c boolean? 0 1)
A contract describing the mode argument to functions
matching custom-write-function/c. See gen:custom-write for
details.
procedure
(make-named-object-custom-write type-name [ #:name-getter get-name]) → custom-write-function/c type-name : symbol? get-name : (-> any/c (or/c symbol? #false)) = object-name
Constructs a custom write implementation that prints values as opaque,
unreadable, named objects, similar to the way functions are printed.
Examples:
> (struct person (name) #:property prop:object-name (struct-field-index name) #:property prop:custom-write (make-named-object-custom-write 'person)) > (person 'alyssa) #<person:alyssa>
> (person 'jared) #<person:jared>
> (person #false) #<person>