40 lines
4.6 KiB
HTML
40 lines
4.6 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 6.1.6</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="06_aea.htm">
|
|
<LINK REL=UP HREF="06_a.htm">
|
|
<LINK REL=NEXT HREF="06_afa.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="06_aea.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="06_a.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="06_afa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<H2>
|
|
6.1.6 Conditional Execution Clauses</H2> <P>
|
|
<P>
|
|
The <TT>if</TT>, <TT>when</TT>, and <TT>unless</TT> constructs establish conditional control in a <A REL=DEFINITION HREF="m_loop.htm#loop"><B>loop</B></A>. If the test passes, the succeeding loop clause is executed. If the test does not pass, the succeeding clause is skipped, and program control moves to the clause that follows the <A REL=DEFINITION HREF="26_glo_l.htm#loop_keyword"><I>loop keyword</I></A> <TT>else</TT>. If the test does not pass and no <TT>else</TT> clause is supplied, control is transferred to the clause or construct following the entire conditional clause. <P>
|
|
If conditional clauses are nested, each <TT>else</TT> is paired with the closest preceding conditional clause that has no associated <TT>else</TT> or <TT>end</TT>. <P>
|
|
In the <TT>if</TT> and <TT>when</TT> clauses, which are synonymous, the test passes if the value of <I>form</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
In the <TT>unless</TT> clause, the test passes if the value of <I>form</I> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<P>
|
|
Clauses that follow the test expression can be grouped by using the <A REL=DEFINITION HREF="26_glo_l.htm#loop_keyword"><I>loop keyword</I></A> <TT>and</TT> to produce a conditional block consisting of a compound clause. <P>
|
|
The <A REL=DEFINITION HREF="26_glo_l.htm#loop_keyword"><I>loop keyword</I></A> <TT>it</TT> can be used to refer to the result of the test expression in a clause. Use the <A REL=DEFINITION HREF="26_glo_l.htm#loop_keyword"><I>loop keyword</I></A> <TT>it</TT> in place of the form in a <TT>return</TT> clause or an <I>accumulation</I> clause that is inside a conditional execution clause. If multiple clauses are connected with <TT>and</TT>, the <TT>it</TT> construct must be in the first clause in the block. <P>
|
|
The optional <A REL=DEFINITION HREF="26_glo_l.htm#loop_keyword"><I>loop keyword</I></A> <TT>end</TT> marks the end of the clause. If this keyword is not supplied, the next <A REL=DEFINITION HREF="26_glo_l.htm#loop_keyword"><I>loop keyword</I></A> marks the end. The construct <TT>end</TT> can be used to distinguish the scoping of compound clauses. <P>
|
|
|
|
|
|
<A REL=CHILD HREF="06_afa.htm"><H2>
|
|
6.1.6.1 Examples of WHEN clause</H2></A><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/iss223.htm">LOOP-MISCELLANEOUS-REPAIRS:FIX</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>
|