next up previous contents index
Next: Example 1: Up: Program Interface Previous: The Tell-Ask Interface

Defining New Commands

(defsnepscom command ([({arg}tex2html_wrap_inline4051)] [ environments] [eval-args]) {body-form}tex2html_wrap_inline4051) 

defsnepscom is a Lisp macro that defines SNePSUL commands. All standard SNePSUL commands such as find, assert, deduce, etc., are defined via defsnepscom. More importantly, defsnepscom is the only way to define commands which will be recognized as legal SNePSUL commands at the SNePS top level. The syntax of defsnepscom is very similar to that of a standard defun or defmacro.

command is a Lisp symbol which serves as the command name, e.g., find, deduce, my-find, isa, etc. command will get exported automatically from its home package and imported into the SNePSUL package, hence, even if the command was defined in a different package, it can be used at the SNePS top level without package qualifiers. The only catch is that if command is the name of a standard COMMON LISP function as in the case of find or assert, then that symbol has to be shadowed in its home package with the COMMON LISP function shadow before the command gets defined.

({arg}tex2html_wrap_inline4051) is an optional argument list in the standard COMMON LISP syntax. An actual call to the command has to be legal according to that argument list, otherwise an error will occur. The only difference to the standard defun style of specifying argument lists is an extra level of nesting as shown in the examples below.

The optional second argument environments defines the places in which the command can legally appear. An environment is basically a specification of a location in which a command can be used. For example, some commands can only be used at the top level, some commands can never be used at the top level but only inside some other command, some commands can only be used within find commands, etc. See Section 1.4 for more information on environments. environments can either be :all to define command as legal in all possible environments, or it can be a subset of (top rs bns fns ons rearrange) specified as a list, which will make it legal in the specified environments. These abbreviations indicate environments as specified in the following table.
tabular1257
A third possibility, which is probably the one most commonly used, is to supply the name of an already existing command, in which case command will be legal in all environments in which the supplied command is legal. environments defaults to (top). According to the specified environments, defsnepscom automatically updates the SNePSUL variables commands, topcommands, etc. (See Section 1.7.)

By default, commands defined with defsnepscom do not evaluate their arguments. If one wants command arguments to be evaluated before they get passed (similar to the behavior of standard functions defined with defun), one has to specify the optional third argument, eval-args as t.

body-forms are a sequence of body forms, possibly including a documentation string and declarations just as in a normal defun. The value/s of the last form will be returned.

Here are some examples:


next up previous contents index
Next: Example 1: Up: Program Interface Previous: The Tell-Ask Interface

John Francis Santore
Fri May 14 11:18:57 EDT 1999