On this page:
custom-write-function/  c
custom-write-mode/  c
make-named-object-custom-write
7.4

7 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.

A contract describing functions suitable for use with prop:custom-write.

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? #f)) = 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 #f)

#<person>