Next: , Previous: Debugging commands, Up: Command processor


2.4.9 Inspector

Scheme48 provides a simple interactive object inspector. The command processor's prompt's end changes from `>' to `:' when in inspection mode. The inspector is the basis of the debugger, which is, for the most part, merely an inspector of continuations. In the debugger, the prompt is `debug:'. In the inspector, objects are printed followed by menus of their components. Entries in the menu are printed with the index, which optionally includes a symbolic name, and the value of the component. For example, a pair whose car is the symbol a and whose cdr is the symbol b would be printed by the inspector like this:

     '(a . b)
     
      [0: car] 'a
      [1: cdr] 'b

The inspector maintains a stack of the focus objects it previously inspected. Selecting a new focus object pushes the current one onto the stack; the u command pops the stack.

— command: ,inspect
— command: ,inspect exp

Invokes the inspector. If exp is present, it is evaluated in the user package and its result is inspected (or a list of results, if it returned multiple values, is inspected). If exp is absent, the current focus value is inspected.

The inspector operates with its own set of commands, separate from the regular interaction commands, although regular commands may be invoked from the inspector as normal. Inspector commands are entered with or without a preceding comma at the inspector prompt. Multiple inspector commands may be entered on one line; an input may also consist of an expression to be evaluated. If an expression is evaluated, its value is selected as the focus object. Note, however, that, since inspector commands are symbols, variables cannot be evaluated just by entering their names; one must use either the ,run command or wrap the variables in a begin.

These inspector commands are defined:

— inspector command: menu
— inspector command: m

Menu prints a menu for the focus object. M moves forward in the current menu if there are more than sixteen items to be displayed.

— inspector command: u

Pops the stack of focus objects, discarding the current one and setting the focus object to the current top of the stack.

— inspector command: q

Quits the inspector, going back into the read-eval-print loop.

— inspector command: template

Attempts to coerce the focus object into a template. If successful, this selects it as the new focus object; if not, this prints an error to that effect. Templates are the static components of closures and continuations: they contain the code for the procedure, the top-level references made by the procedure, literal constants used in the code, and any inferior templates of closures that may be constructed by the code.

— inspector command: d

Goes down to the parent of the continuation being inspected. This command is valid only in the debugger mode, i.e. when the focus object is a continuation.