THE(3cl)

Common Lisp Reference

THE(3cl)

 

NAME

the – specify the types of values returned by a form (special operator)    

SYNOPSIS

 

the value-type form  
→ {
result }*
 

ARGUMENTS and VALUES

value-type —a type specifier; not evaluated.   

form—a form; evaluated.    

results—the values resulting from the evaluation of form. These values must conform to the type supplied by value-type; see below.   

VALID CONTEXT

n/a    

BINDING TYPES AFFECTED

n/a   

DESCRIPTION

the specifies that the values returned by form are of the types specified by value-type. The consequences are undefined if any result is not of the declared type.  

It is permissible for form to yield a different number of values than are specified by value-type, provided that the values for which types are declared are indeed of those types. Missing values are treated as nil for the purposes of checking their types.  

Regardless of number of values declared by value-type, the number of values returned by the the special form is the same as the number of values returned by form.    

AFFECTED BY

(none)    

EXCEPTIONAL SITUATIONS

The consequences are undefined if the values yielded by the form are not of the type specified by value-type.    

NOTES

The values type specifier can be used to indicate the types of multiple values:   

    (the (values integer integer) (floor x y))    
   
(the (values string t)    
       
(gethash the-key the-string-table))    

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)))) #:G9876    
(the fixnum (+ 5 7)) 12    
(the (values) (truncate 3.2 2)) 1, 1.2    
(the integer (truncate 3.2 2)) 1, 1.2    
(the (values integer) (truncate 3.2 2)) 1, 1.2    
(the (values integer float) (truncate 3.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 ((i 100))    
   (
declare (fixnum i))     
   (
the fixnum (1+ i))) 101    
(let* ((x (listabc))    
       (
y 5))    
   (
setf (the fixnum (car x)) y)    
   
x) (5 B C)  

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.