MacroPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Moderately revised from 9.0.
9.0 version

def-function-spec-handler

Arguments: symbol arglist &body body

def-function-spec-handler defines a new kind of function spec handler keyed on symbol, a symbol which is the fspec-first of the function spec. The handler must accept three arguments so arglist must be a list of three elements. The arguments are:

  1. The function spec, which may be in internal or external form. The external form is a list of two or three elements.
  2. The operation. The list of operations is given below.
  3. The extra argument. This argument will be used when needed and ignored when not needed. When the operation is setf, for example, the extra argument is the new value.

The body must return an appropriate value for the operation. The operations are:

:validate Return a boolean indicating whether the place named by the spec exists. This must never signal error.
fboundp Return the function if the function is defined and return nil if the function is not defined. An error must never be signaled on a validated function spec.
:setfable A boolean indicating whether (setf fdefinition) is allowed.
setf Set the function to the third (extra) argument value.
boundp Boolean whether fmakunbound is allowed. Note that this is not the same meaning as the CL function boundp.
fmakunbound Make the function funbound.
block For certain functions (e.g. setf functions) defun is required to wrap the body in a block with a certain name. This operation must return the name based on the spec and is called by the defun macro and the compiler top level. This is a good place to put an error check for functions that may not be defined by defun.
unintern Detach the function-spec from its "oblist" for potential garbage-collection of the entire function spec. Does not do an fmakunbound; i.e. if an operation has squirrelled the function-spec away, it remains fully operational, just as unintern of an fboundp symbol still leaves it fboundp.
:defunable A boolean indicating whether defun can be used on this function-spec.

The function function-name-p returns true when passed a valid function spec defined with def-function-spec-handler. fboundp can be used to determine whether a valid function spec defined with def-function-spec-handler actually names an operator.

Note: with def-function-spec-handler, Allegro CL extends the concept of (setf fdefinition), but it does not extend the concept of defun. So, for example, it is sometimes useful to

(setf (fdefinition '(method foo (bar))) (lambda (<args>) <body>))

but it is not appropriate to

(defun (method foo (bar)) (<args>) <body>)

because defun does not supply enough mechanism to accomodate MOP requirements.

See Function specs in implementation.htm for more information on function specs.


Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 9.0 page.
Created 2019.8.20.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Moderately revised from 9.0.
9.0 version