emacs.d/clones/lisp/HyperSpec-7-0/HyperSpec/Body/f_gentem.htm
2023-01-18 20:30:47 +01:00

73 lines
7.7 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 GENTEMP</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="v_gensym.htm">
<LINK REL=UP HREF="c_symbol.htm">
<LINK REL=NEXT HREF="f_symb_1.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="v_gensym.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_symbol.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_symb_1.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="gentemp"><I>Function</I> <B>GENTEMP</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>gentemp</B> <I><TT>&amp;optional</TT> prefix package</I> =&gt; <I>new-symbol</I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>prefix</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A>. The default is <TT>&quot;T&quot;</TT>. <P>
<I>package</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#package_designator"><I>package designator</I></A>. The default is the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A>. <P>
<I>new-symbol</I>---a <A REL=DEFINITION HREF="26_glo_f.htm#fresh"><I>fresh</I></A>, <A REL=DEFINITION HREF="26_glo_i.htm#interned"><I>interned</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <P>
<P><B>Description:</B><P>
<P>
<A REL=DEFINITION HREF="#gentemp"><B>gentemp</B></A> creates and returns a <A REL=DEFINITION HREF="26_glo_f.htm#fresh"><I>fresh</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>, <A REL=DEFINITION HREF="26_glo_i.htm#interned"><I>interned</I></A> in the indicated <I>package</I>. The <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> is guaranteed to be one that was not previously <A REL=DEFINITION HREF="26_glo_a.htm#accessible"><I>accessible</I></A> in <I>package</I>. It is neither <A REL=DEFINITION HREF="26_glo_b.htm#bound"><I>bound</I></A> nor <A REL=DEFINITION HREF="26_glo_f.htm#fbound"><I>fbound</I></A>, and has a <A REL=DEFINITION HREF="26_glo_n.htm#null"><I>null</I></A> <A REL=DEFINITION HREF="26_glo_p.htm#property_list"><I>property list</I></A>. <P>
The <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> of the <I>new-symbol</I> is the concatenation of the <I>prefix</I> and a suffix, which is taken from an internal counter used only by <A REL=DEFINITION HREF="#gentemp"><B>gentemp</B></A>. (If a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> by that name is already <A REL=DEFINITION HREF="26_glo_a.htm#accessible"><I>accessible</I></A> in <I>package</I>, the counter is incremented as many times as is necessary to produce a <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> that is not already the <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> of a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> <A REL=DEFINITION HREF="26_glo_a.htm#accessible"><I>accessible</I></A> in <I>package</I>.) <P>
<P><B>Examples:</B><P>
<P>
<PRE>
(gentemp) =&gt; T1298
(gentemp &quot;FOO&quot;) =&gt; FOO1299
(find-symbol &quot;FOO1300&quot;) =&gt; NIL, NIL
(gentemp &quot;FOO&quot;) =&gt; FOO1300
(find-symbol &quot;FOO1300&quot;) =&gt; FOO1300, :INTERNAL
(intern &quot;FOO1301&quot;) =&gt; FOO1301, :INTERNAL
(gentemp &quot;FOO&quot;) =&gt; FOO1302
(gentemp) =&gt; T1303
</PRE>
</TT> <P>
<P><B>Side Effects:</B><P>
<P>
Its internal counter is incremented one or more times. <P>
<A REL=DEFINITION HREF="26_glo_i.htm#intern"><I>Interns</I></A> the <I>new-symbol</I> in <I>package</I>. <P>
<P><B>Affected By:</B><P>
<P>
The current state of its internal counter, and the current state of the <I>package</I>. <P>
<P><B>Exceptional Situations:</B><P>
<P>
Should signal an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> if <I>prefix</I> is not a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A>. Should signal an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> if <I>package</I> is not a <A REL=DEFINITION HREF="26_glo_p.htm#package_designator"><I>package designator</I></A>. <P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_gensym.htm#gensym"><B>gensym</B></A> <P>
<P><B>Notes:</B><P>
<P>
The function <A REL=DEFINITION HREF="#gentemp"><B>gentemp</B></A> is deprecated. <P>
If <I>package</I> is the <TT>KEYWORD</TT> package, the result is an <A REL=DEFINITION HREF="26_glo_e.htm#external_symbol"><I>external symbol</I></A> of <I>package</I>. Otherwise, the result is an <A REL=DEFINITION HREF="26_glo_i.htm#internal_symbol"><I>internal symbol</I></A> of <I>package</I>. <P>
The <A REL=DEFINITION HREF="#gentemp"><B>gentemp</B></A> internal counter is independent of <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A>, the counter used by <A REL=DEFINITION HREF="f_gensym.htm#gensym"><B>gensym</B></A>. There is no provision for accessing the <A REL=DEFINITION HREF="#gentemp"><B>gentemp</B></A> internal counter. <P>
Just because <A REL=DEFINITION HREF="#gentemp"><B>gentemp</B></A> creates a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> which did not previously exist does not mean that such a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> might not be seen in the future (e.g., in a data file---perhaps even created by the same program in another session). As such, this symbol is not truly unique in the same sense as a <A REL=DEFINITION HREF="26_glo_g.htm#gensym"><I>gensym</I></A> would be. In particular, programs which do automatic code generation should be careful not to attach global attributes to such generated <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> (e.g., <A REL=DEFINITION HREF="d_specia.htm#special"><B>special</B></A> <A REL=DEFINITION HREF="26_glo_d.htm#declaration"><I>declarations</I></A>) and then write them into a file because such global attributes might, in a different session, end up applying to other <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> that were automatically generated on another day for some other purpose. <P>
<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>