13.9 Structure Inspectors
An inspector provides access to structure fields and structure type information without the normal field accessors and mutators. (Inspectors are also used to control access to module bindings; see Code Inspectors.) Inspectors are primarily intended for use by debuggers.
When a structure type is created, an inspector can be supplied. The given inspector is not the one that will control the new structure type; instead, the given inspector’s parent will control the type. By using the parent of the given inspector, the structure type remains opaque to “peer” code that cannot access the parent inspector.
The current-inspector parameter determines a default inspector argument for new structure types. An alternate inspector can be provided though the #:inspector option of the define-struct form (see Defining Structure Types: struct), or through an optional inspector argument to make-struct-type.
(inspector? v) → boolean? v : any/c
(make-inspector [inspector]) → inspector? inspector : inspector? = (current-inspector)
(make-sibling-inspector [inspector]) → inspector? inspector : inspector? = (current-inspector)
(current-inspector) → inspector? (current-inspector insp) → void? insp : inspector?
(struct-info v) →
(or/c struct-type? #f) boolean? v : any/c
struct-type: a structure type descriptor or #f; the result is a structure type descriptor of the most specific type for which v is an instance, and for which the current inspector has control, or the result is #f if the current inspector does not control any structure type for which the struct is an instance.
skipped?: #f if the first result corresponds to the most specific structure type of v, #t otherwise.
name: the structure type’s name as a symbol;
init-field-cnt: the number of fields defined by the structure type provided to the constructor procedure (not counting fields created by its ancestor types);
auto-field-cnt: the number of fields defined by the structure type without a counterpart in the constructor procedure (not counting fields created by its ancestor types);
accessor-proc: an accessor procedure for the structure type, like the one returned by make-struct-type;
mutator-proc: a mutator procedure for the structure type, like the one returned by make-struct-type;
immutable-k-list: an immutable list of exact non-negative integers that correspond to immutable fields for the structure type;
super-type: a structure type descriptor for the most specific ancestor of the type that is controlled by the current inspector, or #f if no ancestor is controlled by the current inspector;
skipped?: #f if the seventh result is the most specific ancestor type or if the type has no supertype, #t otherwise.
If the type for struct-type is not controlled by the current inspector, the exn:fail:contract exception is raised.
(struct-type-make-constructor struct-type) → struct-constructor-procedure? struct-type : struct-type?
(struct-type-make-predicate struct-type) → any struct-type : any/c
(object-name v) → any v : any/c
The name (if any) of a procedure is always a symbol. The procedure-rename function creates a procedure with a specific name.
The name of a structure, structure type, structure type property is always a symbol. If a structure is a procedure as implemented by one of its fields (i.e., the prop:procedure property value for the structure’s type is an integer), then its name is the implementing procedure’s name; otherwise, its name matches the name of the structure type that it instantiates.
The name of a regexp value is a string or byte string. Passing the string or byte string to regexp, byte-regexp, pregexp, or byte-pregexp (depending on the kind of regexp whose name was extracted) produces a value that matches the same inputs.
The name of a port can be any value, but many tools use a path or string name as the port’s for (to report source locations, for example).