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

75 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: Section 3.4.1</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="03_d.htm">
<LINK REL=UP HREF="03_d.htm">
<LINK REL=NEXT HREF="03_daa.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="03_d.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="03_d.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="03_daa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
3.4.1 Ordinary Lambda Lists</H2> <A NAME="AMoptional"></A> <A NAME="AMrest"></A> <A NAME="AMkey"></A> <A NAME="AMallow-other-keys"></A> <A NAME="AMaux"></A> <P>
An <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_lambda_list"><I>ordinary lambda list</I></A> is used to describe how a set of <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>arguments</I></A> is received by an <I>ordinary</I> <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A>. The <A REL=DEFINITION HREF="26_glo_d.htm#defined_name"><I>defined names</I></A> in the next figure are those which use <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_lambda_list"><I>ordinary lambda lists</I></A>: <P>
<PRE>
<A REL=DEFINITION HREF="m_defi_4.htm#define-method-combination">define-method-combination</A> <A REL=DEFINITION HREF="m_hand_1.htm#handler-case">handler-case</A> <A REL=DEFINITION HREF="m_rst_ca.htm#restart-case">restart-case</A>
<A REL=DEFINITION HREF="m_defun.htm#defun">defun</A> <A REL=DEFINITION HREF="s_flet_.htm#labels">labels</A>
<A REL=DEFINITION HREF="s_flet_.htm#flet">flet</A> <A REL=DEFINITION HREF="a_lambda.htm#lambda">lambda</A>
</PRE>
<P><B>Figure 3-12. Standardized Operators that use Ordinary Lambda Lists</B> <P>
An <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_lambda_list"><I>ordinary lambda list</I></A> can contain the <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list_keyword"><I>lambda list keywords</I></A> shown in the next figure. <P>
<PRE>
&amp;allow-other-keys &amp;key &amp;rest
&amp;aux &amp;optional
</PRE>
<P><B>Figure 3-13. Lambda List Keywords used by Ordinary Lambda Lists</B> <P>
Each <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of a <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list"><I>lambda list</I></A> is either a parameter specifier or a <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list_keyword"><I>lambda list keyword</I></A>. Implementations are free to provide additional <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list_keyword"><I>lambda list keywords</I></A>. For a list of all <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list_keyword"><I>lambda list keywords</I></A> used by the implementation, see <A REL=DEFINITION HREF="v_lambda.htm#lambda-list-keywords"><B>lambda-list-keywords</B></A>. <P>
The syntax for <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_lambda_list"><I>ordinary lambda lists</I></A> is as follows: <P>
<P> <PRE>
lambda-list::= (var*
[&amp;optional {var | (var [init-form [supplied-p-parameter]])}*]
[&amp;rest var]
[&amp;key {var | ({var | (keyword-name var)} [init-form [supplied-p-parameter]])}* [&amp;allow-other-keys]]
[&amp;aux {var | (var [init-form])}*])
</PRE>
<P>
A <I>var</I> or <I>supplied-p-parameter</I> must be a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> that is not the name of a <A REL=DEFINITION HREF="26_glo_c.htm#constant_variable"><I>constant variable</I></A>. <P>
An <I>init-form</I> can be any <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>. Whenever any <I>init-form</I> is evaluated for any parameter specifier, that <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> may refer to any parameter variable to the left of the specifier in which the <I>init-form</I> appears, including any <I>supplied-p-parameter</I> variables, and may rely on the fact that no other parameter variable has yet been bound (including its own parameter variable). <P>
A <I>keyword-name</I> can be any <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>, but by convention is normally a <A REL=DEFINITION HREF="26_glo_k.htm#keyword"><I>keyword</I></A>[1]; all <A REL=DEFINITION HREF="26_glo_s.htm#standardized"><I>standardized</I></A> <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A> follow that convention. <P>
An <A REL=DEFINITION HREF="26_glo_o.htm#ordinary_lambda_list"><I>ordinary lambda list</I></A> has five parts, any or all of which may be empty. For information about the treatment of argument mismatches, see <A REL=CHILD HREF="03_e.htm">Section 3.5 (Error Checking in Function Calls)</A>. <P>
<A REL=CHILD HREF="03_daa.htm"><H2>
3.4.1.1 Specifiers for the required parameters</H2></A><P><P>
<A REL=CHILD HREF="03_dab.htm"><H2>
3.4.1.2 Specifiers for optional parameters</H2></A><P>
<A REL=CHILD HREF="03_dac.htm"><H2>
3.4.1.3 A specifier for a rest parameter</H2></A><P> <P>
<A REL=CHILD HREF="03_dad.htm"><H2>
3.4.1.4 Specifiers for keyword parameters</H2></A><P>
<A REL=CHILD HREF="03_dae.htm"><H2>
3.4.1.5 Specifiers for &amp;aux variables</H2></A><P>
<A REL=CHILD HREF="03_daf.htm"><H2>
3.4.1.6 Examples of Ordinary Lambda Lists</H2></A><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>