80 lines
8.9 KiB
HTML
80 lines
8.9 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Function CONSTANTP</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="f_specia.htm">
|
|
<LINK REL=UP HREF="c_evalua.htm">
|
|
<LINK REL=NEXT HREF="04_.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="f_specia.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_evalua.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="04_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="constantp"><I>Function</I> <B>CONSTANTP</B></A> <P>
|
|
<P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>constantp</B> <I>form <TT>&optional</TT> environment</I> => <I>generalized-boolean</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>form</I>---a <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>. <P>
|
|
<I>environment</I>---an <A REL=DEFINITION HREF="26_glo_e.htm#environment"><I>environment</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. The default is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<I>generalized-boolean</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
Returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if <I>form</I> can be determined by the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> to be a <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant form</I></A> in the indicated <I>environment</I>; otherwise, it returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> indicating either that the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is not a <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant form</I></A> or that it cannot be determined whether or not <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is a <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant form</I></A>. <P>
|
|
The following kinds of <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>forms</I></A> are considered <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant forms</I></A>: <P><DL><DT>* <A REL=DEFINITION HREF="26_glo_s.htm#self-evaluating_object"><I>Self-evaluating objects</I></A> (such as <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>numbers</I></A>, <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A>, and the various kinds of <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>arrays</I></A>) are always considered <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant forms</I></A> and must be recognized as such by <A REL=DEFINITION HREF="#constantp"><B>constantp</B></A>. <P><DD>
|
|
<DT>* <A REL=DEFINITION HREF="26_glo_c.htm#constant_variable"><I>Constant variables</I></A>, such as <A REL=DEFINITION HREF="26_glo_k.htm#keyword"><I>keywords</I></A>, symbols defined by Common Lisp as constant (such as <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>, and <A REL=DEFINITION HREF="v_pi.htm#pi"><B>pi</B></A>), and symbols declared as constant by the user in the indicated <I>environment</I> using <A REL=DEFINITION HREF="m_defcon.htm#defconstant"><B>defconstant</B></A> are always considered <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant forms</I></A> and must be recognized as such by <A REL=DEFINITION HREF="#constantp"><B>constantp</B></A>. <P><DD>
|
|
<DT>* <A REL=DEFINITION HREF="s_quote.htm#quote"><B>quote</B></A> <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>forms</I></A> are always considered <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant forms</I></A> and must be recognized as such by <A REL=DEFINITION HREF="#constantp"><B>constantp</B></A>. <P><DD>
|
|
<DT>* An <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> is permitted, but not required, to detect additional <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant forms</I></A>. If it does, it is also permitted, but not required, to make use of information in the <I>environment</I>. Examples of <A REL=DEFINITION HREF="26_glo_c.htm#constant_form"><I>constant forms</I></A> for which <A REL=DEFINITION HREF="#constantp"><B>constantp</B></A> might or might not return <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> are: <TT>(sqrt pi)</TT>, <TT>(+ 3 2)</TT>, <TT>(length '(a b c))</TT>, and <TT>(let ((x 7)) (zerop x))</TT>. <P><DD></DL><P>
|
|
If an <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> chooses to make use of the <I>environment</I> information, such actions as expanding <A REL=DEFINITION HREF="26_glo_m.htm#macro"><I>macros</I></A> or performing function inlining are permitted to be used, but not required; however, expanding <A REL=DEFINITION HREF="26_glo_c.htm#compiler_macro"><I>compiler macros</I></A> is not permitted. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(constantp 1) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(constantp 'temp) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(constantp ''temp)) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(defconstant this-is-a-constant 'never-changing) => THIS-IS-A-CONSTANT
|
|
(constantp 'this-is-a-constant) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(constantp "temp") => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(setq a 6) => 6
|
|
(constantp a) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(constantp '(sin pi)) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(car '(x))) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(eql x x)) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(typep x 'nil)) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(typep x 't)) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(values this-is-a-constant)) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(values 'x 'y)) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
(constantp '(let ((a '(a b c))) (+ (length a) 6))) => <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent">implementation-dependent</A>
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Side Effects:</B> None.
|
|
<P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
The state of the global environment (e.g., which <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> have been declared to be the <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> of <A REL=DEFINITION HREF="26_glo_c.htm#constant_variable"><I>constant variables</I></A>). <P>
|
|
<P><B>Exceptional Situations:</B> None.
|
|
<P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="m_defcon.htm#defconstant"><B>defconstant</B></A> <P>
|
|
<P><B>Notes:</B> None.
|
|
<P>
|
|
<P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss085.htm">CONSTANTP-ENVIRONMENT:ADD-ARG</A><LI> <A REL=CHILD HREF="../Issues/iss084.htm">CONSTANTP-DEFINITION:INTENTIONAL</A><P></UL><HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|