Dissector 1.7: An object inspector for Chicken -- Copyright (C) 2004, Taylor Campbell All rights reserved. See the LICENCE file for details. -- The dissector is an interactive object structure inspector. It allows for expedient inspection of a tree of objects' components. It consists of a current 'focus object' -- the object currently being dissected --, a menu of that object's components, and an interactive command reader for commands that the user uses to interactively browse the objects. (DISSECT [ []]) ;procedure DISSECT invokes the dissector. If given, INPORT & OUTPORT specify the ports to & from which commands & output are read & written. (Bug, due to csi: when first invoking the dissector, the prompt is printed twice.) Dissector commands are put each on single lines. The first part of the line should be a symbol. The remainder of the line consists of arguments to the command. After certain commands, a summary of the focus object may be printed. This summary is truncated to fit within your terminal. (Actually, it's truncated to fit within 72 lines. But that's usually enough for most terminals.) Other commands may print a selection from the menu of an object's components. In this selection is printed summaries of a number of an object's components. Each component is given a particular index; this index may be used to select the respective subcomponent of the focus object. A list of dissector commands and help for them can be acquired with the HELP command, or the ? alias for it. There are several parameter objects that affect the dissector. DISSECTION-PROMPT -> string ;parameter This specifies the prompt to be printed before waiting for the user to send a command. DISSECTION-MENU-SECTION-SIZE -> exact, positive integer ;parameter This specifies the maximum number of entries to be printed when disclosing a section of a menu to the user. DISSECTION-MENU-SECTION-SIZE -> procedure ;parameter The function to print a dissection's overview. The function takes two arguments: the object to print and the port to print it to. DISSECTION-MENU-ENTRY-PRINTER -> procedure ;parameter The function to print a dissected object's components. It takes three arguments: the object to print, the number of characters already printed to the port on the current line, and the port to print the object to. DISSECTOR-RIGHT-MARGIN -> exact, positive integer ;parameter The right margin for printing objects. This is merely a hint to the DISSECTION-...-PRINTER parameters. Its default is 71, to fit nearly all terminals. Supported dissector commands: apply (a) - Apply a function to the focus object. apply/dissect (ad) - Apply a function to the focus object & dissect its result. dissect (d) - Dissect a completely new object. eval (e scheme) - Evaluate an expression. help (?) - Print help for commands. history (h) - Print the dissection history. menu (m) - Print just the current menu. overview (o) - Print the focus value, without a menu. print (p) - Print out the entirety of the current dissection. quit (q exit) - Quit the dissection. select (s) - Select a component of the focus object to dissect. up (u) - Move back up the history of dissected objects. walk (w) - Walk about in the current menu. apply ;dissector command (aliases: a) Evaluates EXPRESSION in the interaction environment, which should produce a unary function, and applies it to the current focus object. This does not modify the current dissection. apply/dissect ;dissector command (aliases: ad) Evaluates EXPRESSION in the interaction environment, which should produce a unary function, and applies it to the current focus object. It must return at least one value. If it returns one value, that value is dissected; if it returns more than one, a list containing the values is dissected. dissect ;dissector command (aliases: d) Evaluates EXPRESSION in the interaction environment and dissects the value that is produced. EXPRESSION may evaluate to one or more values. With one value, that value is dissected; with more, a list of the values is dissected. eval ;dissector command (aliases: e scheme) Evalutes EXPRESSION in the interaction environment and prints the results. This does not modify the current dissection. help [] ;dissector command (aliases: ?) If COMMAND is absent, prints out a brief help synopsis for every supported command; otherwise prints out help for COMMAND. history ;dissector command (aliases: h) Prints the dissection history. menu ;dissector command (aliases: m) Prints just the current menu. overview ;dissector command (aliases: o) Prints the focus value, without a menu. print ;dissector command (aliases: p) Prints out the entirety of the current dissection. quit ;dissector command (aliases: q exit) Quits the dissector. select [ ...] ;dissector command (aliases: s) Selects the INDEX'th slot in the focus object to dissect next. INDEX must be a valid index into the focus object, as shown by the menu. If more than one index is passed, it is as if the select command were applied multiple times, to each successive index. up [] ;dissector command (aliases: u) Moves COUNT elements back up the history of dissected objects. If COUNT is absent, it defaults to 1. walk [] ;dissector command (aliases: w) Moves the current menu selection by SLOT-COUNT. If SLOT-COUNT is negative, the menu is moved backwards; if it's positive, it is moved forwards. If it is absent, the menu is moved forward by (dissection-menu-section-size) slots. -- Send questions, comments, bugs, et cetera to Taylor Campbell, either via email at campbell@bloodandcoffee.net or via IRC in #scheme or in #chicken on Freenode (irc.freenode.net).