4.5 Structure Utilities
(struct->vector v [opaque-v]) → vector? |
v : any/c |
opaque-v : any/c = '... |
Typically, when (struct? v) is true, then (struct->vector v) exposes at least one field value. It is possible, however, for the only visible types of v to contribute zero fields.
(struct-type? v) → boolean? |
v : any/c |
(struct-constructor-procedure? v) → boolean? |
v : any/c |
(struct-predicate-procedure? v) → boolean? |
v : any/c |
(struct-accessor-procedure? v) → boolean? |
v : any/c |
(struct-mutator-procedure? v) → boolean? |
v : any/c |
(prefab-struct-key v) → (or/c #f symbol? list?) |
v : any/c |
Examples: | ||||||||
|
A key identifies a structure type based on a list with the following items:
A symbol for the structure type’s name.
An exact, nonnegative integer representing the number of non-automatic fields in the structure type, not counting fields from the supertype (if any).
A list of two items, where the first is an exact, nonnegative integer for the number of automatic fields in the structure type that are not from the supertype (if any), and the second element is an arbitrary value that is the value for the automatic fields.
A vector of exact, nonnegative integers that indicate mutable non-automatic fields in the structure type, counting from 0 and not including fields from the supertype (if any).
Nothing else, if the structure type has no supertype. Otherwise, the rest of the list is the key for the supertype.
An empty vector and an auto-field list that starts with 0 can be omitted. Furthermore, the first integer (which indicates the number of non-automatic fields) can be omitted, since it can be inferred from the number of supplied vs. Finally, a single symbol can be used instead of a list that contains only a symbol (in the case that the structure type has no supertype, no automatic fields, and no mutable fields).
The total field count must be no more than 32768. If the number of fields indicated by key is inconsistent with the number of supplied vs, the exn:fail:contract exception is raised.
Examples: | ||||||||||
|
(prefab-key->struct-type key field-count) → struct-type? |
key : (or/c symbol? list?) |
field-count : (integer-in 0 32768) |
If the number of fields indicated by key is inconsistent with field-count, the exn:fail:contract exception is raised.