From e21db99585b550e8aafb9bbdb8c35a9df42985d6 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 14 May 2024 10:50:05 +0200 Subject: [PATCH] * doc/lispref/functions.texi (Declare Form): Rename and update 'ftype' entry. (cherry picked from commit a39a8060124a5c9390cab186dece82ea35164f70) --- doc/lispref/functions.texi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index deca99960c7..dcce4043064 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2715,7 +2715,7 @@ function. This allows function-level control of the safety level used for the code emitted for the function (@pxref{Native-Compilation Variables}). -@item (type @var{type}) +@item (ftype @var{type} &optional @var{function}) Declare @var{type} to be the type of this function. This is used for documentation by @code{describe-function}. Also it can be used by the native compiler (@pxref{Native Compilation}) for improving code @@ -2727,14 +2727,16 @@ without type declaration. interleaved with symbols @code{&optional} and @code{&rest} to match the function's arguments (@pxref{Argument List}). -Here's an example of using @code{type} inside @code{declare} to declare +@var{function} if present should be the name of function being defined. + +Here's an example of using @code{ftype} inside @code{declare} to declare a function @code{positive-p} that takes an argument of type @var{number} and return a @var{boolean}: @lisp @group (defun positive-p (x) - (declare (type (function (number) boolean))) + (declare (ftype (function (number) boolean))) (when (> x 0) t)) @end group @@ -2748,8 +2750,8 @@ argument of type @var{string} and return one of the symbols @lisp @group (defun cons-or-number (x &optional err-msg) - (declare (type (function ((or cons number) &optional string) - (member is-cons is-number)))) + (declare (ftype (function ((or cons number) &optional string) + (member is-cons is-number)))) (if (consp x) 'is-cons (if (numberp x) -- 2.39.5