8.1. The options for `DEFSTRUCT`
Prev | Chapter 8. Structures | Next

## 8.1. The options for `DEFSTRUCT`

### 8.1.1. The `:PRINT-FUNCTION` option

The `:PRINT-FUNCTION` option should contain a lambda expression `(`LAMBDA` (object stream depth) (declare (ignore depth)) ...)` This lambda expression names a `FUNCTION` whose task is to output the external representation of the `STRUCTURE-OBJECT` `object` onto the `STREAM` `stream`. This may be done by outputting text onto the stream using `WRITE-CHAR`, `WRITE-STRING`, `WRITE`, `PRIN1`, `PRINC`, `PRINT`, `PPRINT`, `FORMAT` and the like. The following rules must be obeyed:

- The value of `*PRINT-ESCAPE*` must be respected.
- The treatment of `*PRINT-PRETTY*` is up to you.
- The value of `*PRINT-CIRCLE*` need not be respected. This is managed by the system. (But the print-circle mechanism handles only those objects that are direct or indirect components of the structure.)
- The value of `*PRINT-LEVEL*` is respected by `WRITE`, `PRIN1`, `PRINC`, `PRINT`, `PPRINT`, `FORMAT` instructions `~A`, `~S`, `~W`, and `FORMAT` instructions `~R`, `~D`, `~B`, `~O`, `~X`, `~F`, `~E`, `~G`, `~$` with not-numerical arguments. Therefore the print-level mechanism works automatically if only these functions are used for outputting objects and if they are not called on objects with nesting level > 1. (The print-level mechanism does not recognize how many parentheses you have output. It only counts how many times it was called recursively.)
- The value of `*PRINT-LENGTH*` must be respected, especially if you are outputting an arbitrary number of components.
- The value of `*PRINT-READABLY*` must be respected. Remember that the values of `*PRINT-ESCAPE*`, `*PRINT-LEVEL*`, `*PRINT-LENGTH*` are ignored if `*PRINT-READABLY*` is true. The value of `*PRINT-READABLY*` is respected by `PRINT-UNREADABLE-OBJECT`, `WRITE`, `PRIN1`, `PRINC`, `PRINT`, `PPRINT`, `FORMAT` instructions `~A`, `~S`, `~W`, and `FORMAT` instructions `~R`, `~D`, `~B`, `~O`, `~X`, `~F`, `~E`, `~G`, `~$` with not-numerical arguments. Therefore `*PRINT-READABLY*` will be respected automatically if only these functions are used for printing objects.
- You need not worry about the values of `*PRINT-BASE*`, `*PRINT-RADIX*`, `*PRINT-CASE*`, `*PRINT-GENSYM*`, `*PRINT-ARRAY*`, `CUSTOM:*PRINT-CLOSURE*`, `CUSTOM:*PRINT-RPARS*`, `CUSTOM:*PRINT-INDENT-LISTS*`.

### 8.1.2. The `:INHERIT` option

The `:INHERIT` option is exactly like `:INCLUDE` except that it does not create new accessors for the inherited slots (this is a CLISP extension).

| These notes document CLISP version 2.45 | Last modified: 2008-05-14

Enter your search termsSubmit search form
Webclisp.cons.orgclisp.podval.orgwww.lisp.org

Prev | Up | Next
Chapter 8. Structures | Home | 8.2. The structure Meta-Object Protocol