62 lines
8.3 KiB
HTML
62 lines
8.3 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 ENSURE-GENERIC-FUNCTION</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_fn_kwd.htm">
|
|
<LINK REL=UP HREF="c_object.htm">
|
|
<LINK REL=NEXT HREF="f_alloca.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_fn_kwd.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_object.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_alloca.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="ensure-generic-function"><I>Function</I> <B>ENSURE-GENERIC-FUNCTION</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>ensure-generic-function</B> <I>function-name <TT>&key</TT> argument-precedence-order declare documentation environment generic-function-class lambda-list method-class method-combination</I><P> => <I>generic-function</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>function-name</I>---a <A REL=DEFINITION HREF="26_glo_f.htm#function_name"><I>function name</I></A>. <P>
|
|
The keyword arguments correspond to the <I>option</I> arguments of <A REL=DEFINITION HREF="m_defgen.htm#defgeneric"><B>defgeneric</B></A>, except that the <TT>:method-class</TT> and <TT>:generic-function-class</TT> arguments can be <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>s as well as names. <P>
|
|
<TT>Method-combination</TT> -- method combination object. <P>
|
|
<TT>Environment</TT> -- the same as the <TT>&environment</TT> argument to macro expansion functions and is used to distinguish between compile-time and run-time environments. <P>
|
|
<I>generic-function</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="#ensure-generic-function"><B>ensure-generic-function</B></A> is used to define a globally named <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> with no <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> or to specify or modify options and declarations that pertain to a globally named <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> as a whole. <P>
|
|
If <I>function-name</I> is not <A REL=DEFINITION HREF="26_glo_f.htm#fbound"><I>fbound</I></A> in the <A REL=DEFINITION HREF="26_glo_g.htm#global_environment"><I>global environment</I></A>, a new <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> is created. If <TT>(fdefinition </TT><I>function-name</I><TT>)</TT> is an <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_function"><I>ordinary function</I></A>, a <A REL=DEFINITION HREF="26_glo_m.htm#macro"><I>macro</I></A>, or a <A REL=DEFINITION HREF="26_glo_s.htm#special_operator"><I>special operator</I></A>, an error is signaled. <P>
|
|
If <I>function-name</I> is a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A>, it must be of the form <TT>(setf </TT><I>symbol</I><TT>)</TT>. If <I>function-name</I> specifies a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> that has a different value for any of the following arguments, the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> is modified to have the new value: <TT>:argument-precedence-order</TT>, <TT>:declare</TT>, <TT>:documentation</TT>, <TT>:method-combination</TT>. <P>
|
|
If <I>function-name</I> specifies a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> that has a different value for the <TT>:lambda-list</TT> argument, and the new value is congruent with the <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list"><I>lambda lists</I></A> of all existing <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> or there are no <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A>, the value is changed; otherwise an error is signaled. <P>
|
|
If <I>function-name</I> specifies a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> that has a different value for the <TT>:generic-function-class</TT> argument and if the new generic function class is compatible with the old, <A REL=DEFINITION HREF="f_chg_cl.htm#change-class"><B>change-class</B></A> is called to change the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A>; otherwise an error is signaled. <P>
|
|
If <I>function-name</I> specifies a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> that has a different value for the <TT>:method-class</TT> argument, the value is changed, but any existing <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> are not changed. <P>
|
|
<P><B>Examples:</B> None.
|
|
<P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
Existing function binding of <I>function-name</I>. <P>
|
|
<P><B>Exceptional Situations:</B><P>
|
|
<P>
|
|
If <TT>(fdefinition </TT><I>function-name</I><TT>)</TT> is an <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_function"><I>ordinary function</I></A>, a <A REL=DEFINITION HREF="26_glo_m.htm#macro"><I>macro</I></A>, or a <A REL=DEFINITION HREF="26_glo_s.htm#special_operator"><I>special operator</I></A>, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_error.htm#error"><B>error</B></A> is signaled. <P>
|
|
If <I>function-name</I> specifies a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> that has a different value for the <TT>:lambda-list</TT> argument, and the new value is not congruent with the <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list"><I>lambda list</I></A> of any existing <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A>, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_error.htm#error"><B>error</B></A> is signaled. <P>
|
|
If <I>function-name</I> specifies a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> that has a different value for the <TT>:generic-function-class</TT> argument and if the new generic function class not is compatible with the old, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_error.htm#error"><B>error</B></A> is signaled. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="m_defgen.htm#defgeneric"><B>defgeneric</B></A> <P>
|
|
<P><B>Notes:</B> None.
|
|
<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/iss174.htm">FUNCTION-NAME:LARGE</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>
|