CONSTANTP(3cl)

Common Lisp Reference

CONSTANTP(3cl)

 

NAME

constantp – query whether a form can be determined to be constant in the indicated environment (function)    

SYNOPSIS

 

constantp form &optional environment  
generalized-boolean  
 

ARGUMENTS and VALUES

form—a form.    

environment—an environment object. The default is nil.   

generalized-boolean—a generalized boolean.       

VALID CONTEXT

n/a    

BINDING TYPES AFFECTED

n/a   

DESCRIPTION

Returns true if form can be determined by the implementation to be a constant form in the indicated environment; otherwise, it returns false indicating either that the form is not a constant form or that it cannot be determined whether or not form is a constant form.    

The following kinds of forms are considered constant forms:    

If an implementation chooses to make use of the environment information, such actions as expanding macros or performing function inlining are permitted to be used, but not required; however, expanding compiler macros is not permitted.

AFFECTED BY

The state of the global environment (e.g., which symbols have been declared to be the names of constant variables).   

EXCEPTIONAL SITUATIONS

(none)   

NOTES

(none)    

EXAMPLES

 
(constantp 1) true    
(
constantptemp) false    
(
constantp ’’temp)) true    
(
defconstant this-is-a-constantnever-changing)    
THIS-IS-A-CONSTANT    
(
constantpthis-is-a-constant) true    
(
constantp "temp") true    
(
setq a 6) 6    
(
constantp a) true    
(
constantp ’(sin pi)) implementation-dependent    
(
constantp ’(car ’(x))) implementation-dependent    
(
constantp ’(eql x x)) implementation-dependent    
(
constantp ’(typep xnil)) implementation-dependent    
(
constantp ’(typep xt)) implementation-dependent    
(
constantp ’(values this-is-a-constant))    
implementation-dependent    
(
constantp ’(valuesxy)) implementation-dependent    
(
constantp ’(let ((a ’(a b c))) (+ (length a) 6)))    
implementation-dependent       

SEE ALSO

defconstant(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.