A command is an object that represents a user interaction. Commands are stored as a cons of the command name and a list of the command's arguments. All positional arguments will be represented in the command object, but only those keywords arguments that were explicitly supplied by the user will be included. When the first element of the cons is apply'ed to the rest of the cons, the code representing that interaction is executed. [annotate]
A partial command is a command object with the value of *unsupplied-argument-marker* in place of any argument that needs to be filled in. [annotate]
Every command is named by command name, which is a symbol. To avoid collisions among command names, application frames should reside in their own package; for example, the com-show-chart command might be defined for both a spreadsheet and a medical application. [annotate]
Given a command object command, returns the command name. [annotate] |
Given a command object command, returns the command's arguments. [annotate] |
Returns true if the command is a partial command, that is, has any occurrences of *unsupplied-argument-marker* in it. Otherwise, partial-command-p returns false. [annotate] |
This is the most basic command-defining form. Usually, the programmer will not use define-command directly, but will instead use a define-frame-command form that is automatically generated by define-application-frame. define-frame-command adds the command to the application frame's command table. By default, define-command does not add the command to any command table. [annotate] name-and-options is either a command name, or a cons of the command name and a list of keyword-value pairs. [annotate] define-command defines two functions. The first function has the same name as the command name, and implements the body of the command. It takes as arguments the arguments to the command as specified by the define-command form, as required and keyword arguments. [annotate] The name of the other function defined by define-command is unspecified. It implements the code used by the command processor for parsing and returning the command's arguments. [annotate] The keywords from name-and-options can be: [annotate]
The :name, :menu, and :keystroke options are only allowed if the :command-table option was supplied explicitly or implicitly, as in define-frame-command. [annotate] arguments is a list consisting of argument descriptions. A single occurrence of the symbol &key may appear in arguments to separate required command arguments from keyword arguments. Each argument description consists of a parameter variable, followed by a presentation type specifier, followed by keyword-value pairs. The keywords can be: [annotate]
body implements the body of the command. It has lexical access to all of the commands arguments. If the body of the command needs access to the application frame itself, it should use *application-frame*. The returned values of body are ignored. body may have zero or more declarations as its first forms. [annotate] define-command must arrange for the function that implements the body of the command to get the proper values for unsupplied keyword arguments. [annotate] name-and-options and body are not evaluated. In the argument descriptions, the parameter variable name is not evaluated, and everything else is evaluated at run-time when argument parsing reaches that argument, except that the value for :when is evaluated when parsing reaches the keyword arguments, and :gesture isn't evaluated at all. [annotate] Note: This paragraph seems insane to me. Are variables in the key positions allowed? If so, then the potential for confusion is high: already (define-command com-foo ((x *type*)) ...) seems to have little utility, but (define-command com-foo ((x *type* *arg1* *arg2*)) ...) seems just mad. Furthermore, what if *arg1* evalutes to :gesture? I think if I were rewriting this paragraph I would specify that the keywords had to be macroexpand-time constants, while those values needing evaluation would be dealt with as in defclass (with its initform / initfunction handling). [edit]-- Christophe Rhodes 2006-04-25 16:58Z |