THE(3cl) |
Common Lisp Reference |
THE(3cl) |
NAME
the – specify the types of values returned by a form (special operator)
SYNOPSIS
the
|
ARGUMENTS and VALUES
—a type specifier; not evaluated.
—a form; evaluated.
s—the values resulting from the evaluation of . These values must conform to the type supplied by ; see below.
VALID CONTEXT
n/a
BINDING TYPES AFFECTED
n/a
DESCRIPTION
the specifies that the values returned by are of the types specified by . The consequences are undefined if any is not of the declared type.
It is permissible for nil for the purposes of checking their types. to yield a different number of values than are specified by , provided that the values for which types are declared are indeed of those types. Missing values are treated as
Regardless of number of values declared by , the number of values returned by the the special form is the same as the number of values returned by .
AFFECTED BY
(none)
EXCEPTIONAL SITUATIONS
The consequences are undefined if the values yielded by the are not of the type specified by .
NOTES
The values type specifier can be used to indicate the types of multiple values:
(the (values integer integer) (floor ))
(the (values string t)
(gethash ))
setf can be used with the type declarations. In this case the declaration is transferred to the form that specifies the new value. The resulting setf form is then analyzed.
EXAMPLES
(the symbol(car(list(gensym))))#:(the fixnum(+5 7))12(the(values) (truncate3.2 2))1,1.2(the integer(truncate3.2 2))1,1.2(the(values integer) (truncate3.2 2))1,1.2(the(values integer float) (truncate3.2 2))1,1.2(the (values integer float symbol) (truncate 3.2 2))
1, 1.2(the (values integer float symbol t null list)
(truncate 3.2 2)) 1,1.2(let (( 100))
(declare (fixnum ))
(the fixnum (1+ )))101(let* (( (list ’ ’ ’))
( 5))
(setf (the fixnum (car )) )
) (5 )
SEE ALSO
values(3cl)
AUTHOR and COPYRIGHT
Substantial portions of this page are taken from draft proposed American National Standard for Information Systems—Programming Language—Common Lisp, X3J13/94-101R, Version 15.17R, Fri 12-Aug-1994 6:35pm EDT; no copyright indicated.
Additional clarification and comments by Michael Marking <marking@tatanka.com>, http://www.tatanka.com/software/cl-manpages/; alternatively, https://github.com/wakinyantanka/cl-manpages/. Copyright 2017 Michael Marking as both an original and a derivative work.
Licensed under Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0).
This page last revised Saturday 18 March 2017.