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
&optional
|
ARGUMENTS and VALUES
—a form.
nil. —an environment object. The default is
—a generalized boolean.
VALID CONTEXT
n/a
BINDING TYPES AFFECTED
n/a
DESCRIPTION
Returns true if can be determined by the implementation to be a constant form in the indicated ; otherwise, it returns false indicating either that the form is not a constant form or that it cannot be determined whether or not is a constant form.
The following kinds of forms are considered constant forms:
Self-evaluating objects (such as numbers, characters, and the various kinds of arrays) are always considered constant forms and must be recognized as such by constantp.
Constant variables, such as keywords, symbols defined by Common Lisp as constant (such as nil, t, and pi), and symbols declared as constant by the user in the indicated using defconstant are always considered constant forms and must be recognized as such by constantp.
quote forms are always considered constant forms and must be recognized as such by constantp.
An implementation is permitted, but not required, to detect additional constant forms. If it does, it is also permitted, but not required, to make use of information in the constantp might or might not return true are: (sqrt pi), (+ 3 2), (length ’()), and (let ((7)) (zerop)). . Examples of constant forms for which
If an implementation chooses to make use of the 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
(constantp ’) false
(constantp ’’)) true
(defconstant ’)
(constantp ’) true
(constantp "temp") true
(setq 6) 6
(constantp ) true
(constantp ’(sin pi)) implementation-dependent
(constantp ’(car ’())) implementation-dependent
(constantp ’(eql )) implementation-dependent
(constantp ’(typep ’nil)) implementation-dependent
(constantp ’(typep ’t)) implementation-dependent
(constantp ’(values ))
implementation-dependent
(constantp ’(values ’ ’)) implementation-dependent
(constantp ’(let (( ’())) (+ (length ) 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.