Declaration ftype

Syntax:

(ftype type {function-name}*)

Arguments:

function-name—a function name.

added --sjl 7 Mar 92type—a type specifier.

Valid Context:

declaration or proclamation

Binding Types Affected:

function

Description:

Specifies that the functions named by function-names are of the functional type type. For example:

 (declare (ftype (function (integer list) t) ith)
          (ftype (function (number) float) sine cosine))
If one of the functions mentioned has a lexically apparent local definition (as made by flet or labels), then the declaration applies to that local definition and not to the global function definition. ftype declarations never apply to variable bindings (see type).

added. --sjl 4 Mar 92 The lexically apparent bindings of function-names must not be macro definitions. (This is because ftype declares the functional definition of each function name to be of a particular subtype of function, and macros do not denote functions.)

This is adequately covered in the packages chapter. --sjl 5 Mar 92 \issue{LISP-SYMBOL-REDEFINITION:MAR89-X3J13} Except where explicitly allowed, the consequences are undefined if a \term{symbol} in \thepackage{common-lisp} is used as a \param{function-name} argument. If such a \term{symbol} is not defined "by this standard" added per barmar: -kmp 28-Dec-90 by this standard as a \term{function}, \term{macro}, or \term{special form}, it is allowed to declare the \declref{ftype} of that \term{binding}. \endissue{LISP-SYMBOL-REDEFINITION:MAR89-X3J13}

ftype and \declref{function} declarations can be free declarations or bound declarations. ftype declarations of functions that appear before the body of a flet or labels \specref{with-added-methods}, \specref{generic-flet}, and \specref{generic-labels} form that defines that function are bound declarations. Such declarations in other contexts are free declarations.

{\tt (function \param{var1} \param{var2}...)} is equivalent to {\tt (type function \param{var1} \param{var2}...)} 9.2.0 12 If one of the \term{functions} mentioned has a lexically apparent local definition (as made by \specref{flet} or \specref{labels}), then the declaration applies to that local definition and not to the global function definition. See \declref{type} and \declref{ftype}.

See Also:

declare, declaim, proclaim