1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss085_w.htm
2024-04-01 10:24:07 +02:00

136 lines
7.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: Issue CONSTANTP-ENVIRONMENT Writeup</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="../Issues/iss084_w.htm">
<LINK REL=UP HREF="../Issues/iss085.htm">
<LINK REL=NEXT HREF="../Issues/iss086_w.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="../Issues/iss084_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss085.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss086_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue CONSTANTP-ENVIRONMENT Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss085.htm">CONSTANTP-ENVIRONMENT</A><P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A><P>
Related issues: <A HREF="iss059.htm">COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS</A><P>
<A HREF="iss099.htm">DEFCONSTANT-SPECIAL</A><P>
<A HREF="iss334.htm">SUBTYPEP-ENVIRONMENT</A><P>
<A HREF="iss340.htm">SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS</A><P>
<A HREF="iss084.htm">CONSTANTP-DEFINITION</A><P>
<B>Category:</B> CHANGE, ADDITION<P>
<B>Edit history:</B> v1, 12 Feb 1991, Sandra Loosemore<P>
v2, 15 Feb 1991, Sandra Loosemore (comments from KAB)<P>
v3, 13 Mar 1991, Sandra Loosemore<P>
<P>
<B>Problem description:<P>
</B><P>
It is permitted for <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> to note the definition of the constant<P>
at compile-time in such a way that the definition is visible only to<P>
the file compiler and not to the evaluator. This can lead to<P>
incorrect behavior in user code that uses <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A>, for example in<P>
macro expansion functions. Such code needs to explicitly indicate in<P>
some way whether it wishes to deal with constant definitions in the<P>
environment seen by the file compiler (the &quot;remote environment&quot;), or<P>
in the current environment.<P>
<P>
<B>Proposal (CONSTANTP-ENVIRONMENT:ADD-ARG):<P>
</B><P>
Add an optional environment argument to the function <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A>. If<P>
the argument is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> or not supplied, it defaults to the null lexical <P>
and the current global environment.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> may use the environment to determine whether a symbol has<P>
been globally defined as a constant (as with <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A>).<P>
<P>
Unless at least one of proposals <A HREF="iss084.htm">CONSTANTP-DEFINITION:INTENTIONAL</A>, <P>
CONSTANTP-DEFINITION:ADD-ARGUMENT, or <P>
SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS:SHADOWING-PERMITTED is accepted,<P>
the value returned by <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> may not depend on lexical information<P>
in the environment.<P>
<P>
<B>Examples:<P>
</B><P>
???<P>
<P>
<B>Rationale:<P>
</B><P>
It solves the problem in a way that is consistent with the way it is<P>
handled in other places in the language.<P>
<P>
<B>Current Practice:<P>
</B><P>
Chestnut's Lisp-to-C translator implements this proposal.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
The cost of adding the environment argument is quite small.<P>
In implementations that do not support remote environments, the argument<P>
can simply be ignored.<P>
<P>
<B>Cost to Users:<P>
</B><P>
The behavior of existing programs that call <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> without an <P>
environment argument will not be affected. However, there is some<P>
motivation for users to change calls to <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> to pass an environment<P>
argument where appropriate, since in implementations that do support <P>
remote environments, calling <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> without an environment argument<P>
might result in <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> being returned for some things that could otherwise<P>
have been detected as constant.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
Some programs will work incorrectly.<P>
<P>
<B>Performance impact:<P>
</B><P>
Minor.<P>
<P>
<B>Benefits:<P>
</B><P>
The cost of non-adoption is avoided.<P>
<P>
<B>Esthetics:<P>
</B><P>
Looks OK to me.<P>
<P>
<B>Discussion:<P>
</B><P>
If proposal SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS:SHADOWING-PERMITTED<P>
is accepted, <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> needs to accept an environment argument so that<P>
it can detect when a defined constant has been lexically shadowed by a <P>
symbol macro.<P>
<P>
If proposal <A HREF="iss084.htm">CONSTANTP-DEFINITION:INTENTIONAL</A> or ADD-ARGUMENT passes,<P>
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> needs to accept an environment argument so that it can perform<P>
the additional kinds of analysis these proposals permit (such as<P>
macroexpansion) in the correct lexical environment.<P>
<P>
Proposal <A HREF="iss085.htm">CONSTANTP-ENVIRONMENT:ADD-ARG</A> only extends the syntax of<P>
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> and permits <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> to use *global* information in the<P>
environment. Issues <A HREF="iss340.htm">SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS</A> and<P>
<A HREF="iss084.htm">CONSTANTP-DEFINITION</A> include proposals that would <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> that <P>
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> also be sensitive to *lexical* information in the environment.<P>
The costs to users and implementors that this would involve are<P>
potentially much higher, but are more properly costs associated with<P>
those other proposals, not <A HREF="iss085.htm">CONSTANTP-ENVIRONMENT:ADD-ARG</A>.<P>
<P>
<P>
</PRE>
<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>