Command Expressions [Topic]

A number of Stella's commands evaluate "command expressions", or exprs, whose results are then processed by the command in some manner. For example, the set command evaluates exprs to return new slot values for the referenced objects. The map command evaluates exprs in the context of each referenced object to compute statistics that are displayed in an information table. A command expression may be as simple as a variable or slot name, or may involve complicated parenthetical expressions. Though exprs are evaluated and may involve Lisp's prefix notation, they are not strictly Lisp. Exprs implement a number of changes and additions to basic Lisp syntax in order to support a comfortable yet terse input style. For example, the simple command expression:

rhythm
is roughly equivalent to the Lisp expression:
(or (and (slot-exists-p (mapped-object) 'rhythm)
         (slot-boundp (mapped-object) 'rhythm)
         (slot-value (mapped-object) 'rhythm)
    0)
Since command expressions are not strictly Lisp, they are only meaningful in conjunction with commands that understand their syntax and evaluation rules. These commands are: increment, invert, map, scale, set, transpose and unset. These commands are called mapping commands because they all map expressions over the references supplied to the command and evaluate each expressions in the context of each mapped object. The expressions rhythm, then, really means: "the value of the slot named rhythm in the currently mapped object, or 0 if that object has no rhythm." Note that when referencing by group there is no "currently mapped object" to speak of, since all members of a group are mapped in parallel. To access slot values and so fourth of an object within the currently mapped group, the access must be qualified with the object's index into the group. This index ranges from 1 to the width of the group, and is specified inside brackets after the basic name. For example:
Stella [Top-Level]: map :::2 find (= rhythm[1] rhythm[2])
would perform a pairwise examination of all the objects in * and return the index of each pair of objects that have the same value in their rhythm slots.

Command expression syntax and evaluation rules

Here is a brief summary of the syntax and evaluation rules for command expressions.

There are also several variables that are useful when working with value expressions.

See Also:

increment [Command], invert [Command], map [Command], scale [Command], set [Command], transpose [Command] unset [Command]


Last Modified: 5-Mar-1998