71 lines
6.8 KiB
HTML
71 lines
6.8 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 GENSYM</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_cp_sym.htm">
|
|
<LINK REL=UP HREF="c_symbol.htm">
|
|
<LINK REL=NEXT HREF="v_gensym.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_cp_sym.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="v_gensym.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="gensym"><I>Function</I> <B>GENSYM</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>gensym</B> <I><TT>&optional</TT> x</I> => <I>new-symbol</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>x</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> or a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>. Complicated defaulting behavior; see below. <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_u.htm#uninterned"><I>uninterned</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
Creates and returns a <A REL=DEFINITION HREF="26_glo_f.htm#fresh"><I>fresh</I></A>, <A REL=DEFINITION HREF="26_glo_u.htm#uninterned"><I>uninterned</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>, as if by calling <A REL=DEFINITION HREF="f_mk_sym.htm#make-symbol"><B>make-symbol</B></A>. (The only difference between <A REL=DEFINITION HREF="#gensym"><B>gensym</B></A> and <A REL=DEFINITION HREF="f_mk_sym.htm#make-symbol"><B>make-symbol</B></A> is in how the <I>new-symbol</I>'s <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> is determined.) <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 a prefix, which defaults to <TT>"G"</TT>, and a suffix, which is the decimal representation of a number that defaults to the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A>. <P>
|
|
If <I>x</I> is supplied, and is a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A>, then that <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> is used as a prefix instead of <TT>"G"</TT> for this call to <A REL=DEFINITION HREF="#gensym"><B>gensym</B></A> only. <P>
|
|
If <I>x</I> is supplied, and is an <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, then that <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, instead of the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A>, is used as the suffix for this call to <A REL=DEFINITION HREF="#gensym"><B>gensym</B></A> only. <P>
|
|
If and only if no explicit suffix is supplied, <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A> is incremented after it is used. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(setq sym1 (gensym)) => #:G3142
|
|
(symbol-package sym1) => NIL
|
|
(setq sym2 (gensym 100)) => #:G100
|
|
(setq sym3 (gensym 100)) => #:G100
|
|
(eq sym2 sym3) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(find-symbol "G100") => NIL, NIL
|
|
(gensym "T") => #:T3143
|
|
(gensym) => #:G3144
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Side Effects:</B><P>
|
|
<P>
|
|
Might increment <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A>. <P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A> <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>x</I> is not a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> or a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_gentem.htm#gentemp"><B>gentemp</B></A>, <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
The ability to pass a numeric argument to <A REL=DEFINITION HREF="#gensym"><B>gensym</B></A> has been deprecated; explicitly <A REL=DEFINITION HREF="26_glo_b.htm#binding"><I>binding</I></A> <A REL=DEFINITION HREF="v_gensym.htm#STgensym-counterST"><B>*gensym-counter*</B></A> is now stylistically preferred. (The somewhat baroque conventions for the optional argument are historical in nature, and supported primarily for compatibility with older dialects of Lisp. In modern code, it is recommended that the only kind of argument used be a string prefix. In general, though, to obtain more flexible control of the <I>new-symbol</I>'s <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A>, consider using <A REL=DEFINITION HREF="f_mk_sym.htm#make-symbol"><B>make-symbol</B></A> instead.) <P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss182.htm">GENSYM-NAME-STICKINESS:LIKE-TEFLON</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>
|