next up previous
Next: Attaching and Detaching Up: Elaboration of Hooks Previous: Elaboration of Hooks

The Hook Construct

  A hook is defined to be a special form with the following appearance:

(hook (hook-id actual-parameter-list)
default-forms)

A hook is considered as a definition of an open point at the location where it appears in the program. If one or more procedures are attached to the hook a so-called hook-combinator controls the applications of attached procedures on the actual parameter list (see section 5.3). In that case the hook combinator also defines the resulting value of the hook construct. If no procedures are attached to the hook, the default forms are evaluated as if they were embedded in a progn form, and and the value of the progn-form is returned as the value of the hook construct. If no default forms are present, nil is returned.

It should be stressed that a hook is regarded as a definition, which binds the name of a hook to an open point in the program. In other words, hook-id of the hook construct is a defining name occurrence. Besides being a definition, a hook is also a construct which causes the attached procedures to be executed.gif Compared with the more simple interpretation, where a hook is regarded as one or more procedure calls, this is an important difference.

Given the view that a hook is a definition, it makes sense to talk about its scope (the part of the program, in which the hook has effect). The attachment must take place in the scope of the hook. The scope of a hook may depend on the concrete Lisp dialect. One particular simple solution is to apply indefinite scope [13] for hooks (hook definitions have effect on the entire program).



Kurt Noermark
Wed Mar 6 09:44:24 MET 1996