1 Language Model
2 Syntactic Forms
3 Datatypes
4 Structures
5 Classes and Objects
6 Units
7 Contracts
8 Pattern Matching
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Bibliography
Index
On this page:
inspector?
make-inspector
make-sibling-inspector
current-inspector
struct-info
struct-type-info
struct-type-make-constructor
struct-type-make-predicate
object-name
Version: 4.0.2

 

13.8 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: define-struct), or through an optional inspector argument to make-struct-type.

(inspector? v)  boolean?

  v : any/c

Returns #t if v is an inspector, #f otherwise.

(make-inspector [inspector])  inspector?

  inspector : inspector? = (current-inspector)

Returns a new inspector that is a subinspector of inspector. Any structure type controlled by the new inspector is also controlled by its ancestor inspectors, but no other inspectors.

(make-sibling-inspector [inspector])  inspector?

  inspector : inspector? = (current-inspector)

Returns a new inspector that is a subinspector of the same inspector as inspector. That is, inspector and the result inspector control mutually disjoint sets of structure types.

(current-inspector)  inspector?

(current-inspector insp)  void?

  insp : inspector?

A parameter that determines the default inspector for newly created structure types.

(struct-info v)

 

 

(or/c struct-type? false/c)

 

boolean?

  v : any/c

Returns two values:

(struct-type-info struct-type)

 

 

symbol?

nonnegative-exact-integer?

nonnegative-exact-integer?

struct-accessor-procedure?

struct-mutator-procedure?

(listof nonnegative-exact-integer?)

(or/c struct-type? false/c)

boolean?

  struct-type : struct-type?

Returns eight values that provide information about the structure type descriptor struct-type, assuming that the type is controlled by the current inspector:

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?

Returns a constructor procedure to create instances of the type for struct-type. If the type for struct-type is not controlled by the current inspector, the exn:fail:contract exception is raised.

(struct-type-make-predicate struct-type)  any

  struct-type : any/c

Returns a predicate procedure to recognize instances of the type for struct-type. If the type for struct-type is not controlled by the current inspector, the exn:fail:contract exception is raised.

(object-name v)  any

  v : any/c

Returns a value for the name of v if v has a name, #f otherwise. The argument v can be any value, but only (some) procedures, structs, struct types, struct type properties, regexp values, and ports have names. The name of a procedure, struct, struct type, or struct type property is always a symbol. The name of a regexp value is a string, and a byte-regexp value’s name is a byte string. The name of a port is typically a path or a string, but it can be arbitrary. See also Inferred Value Names.