Previous: , Up: Procedures   [Contents][Index]


12.5 Application Hooks

Application hooks are objects that can be applied like procedures. Each application hook has two parts: a procedure that specifies what to do when the application hook is applied, and an arbitrary object, called extra. Often the procedure uses the extra object to determine what to do.

There are two kinds of application hooks, which differ in what arguments are passed to the procedure. When an apply hook is applied, the procedure is passed exactly the same arguments that were passed to the apply hook. When an entity is applied, the entity itself is passed as the first argument, followed by the other arguments that were passed to the entity.

Both apply hooks and entities satisfy the predicate procedure?. Each satisfies either compiled-procedure?, compound-procedure?, or primitive-procedure?, depending on its procedure component. An apply hook is considered to accept the same number of arguments as its procedure, while an entity is considered to accept one less argument than its procedure.

procedure: make-apply-hook procedure object

Returns a newly allocated apply hook with a procedure component of procedure and an extra component of object.

procedure: apply-hook? object

Returns #t if object is an apply hook; otherwise returns #f.

procedure: apply-hook-procedure apply-hook

Returns the procedure component of apply-hook.

procedure: set-apply-hook-procedure! apply-hook procedure

Changes the procedure component of apply-hook to be procedure. Returns an unspecified value.

procedure: apply-hook-extra apply-hook

Returns the extra component of apply-hook.

procedure: set-apply-hook-extra! apply-hook object

Changes the extra component of apply-hook to be object. Returns an unspecified value.

procedure: make-entity procedure object

Returns a newly allocated entity with a procedure component of procedure and an extra component of object.

procedure: entity? object

Returns #t if object is an entity; otherwise returns #f.

procedure: entity-procedure entity

Returns the procedure component of entity.

procedure: set-entity-procedure! entity procedure

Changes the procedure component of entity to be procedure. Returns an unspecified value.

procedure: entity-extra entity

Returns the extra component of entity.

procedure: set-entity-extra! entity object

Changes the extra component of entity to be object. Returns an unspecified value.


Previous: , Up: Procedures   [Contents][Index]