<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14"> <TITLE> Expressions </TITLE> </HEAD> <BODY TEXT=black BGCOLOR=white> <A HREF="manual014.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual016.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> <HR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc65"><B><FONT SIZE=5>6.7</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Expressions</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="s:value-expr"></A> <A NAME="@manual.kwd8"></A> <A NAME="@manual.kwd9"></A> <A NAME="@manual.kwd10"></A> <A NAME="@manual.kwd11"></A> <A NAME="@manual.kwd12"></A> <A NAME="@manual.kwd13"></A> <A NAME="@manual.kwd14"></A> <A NAME="@manual.kwd15"></A> <A NAME="@manual.kwd16"></A> <A NAME="@manual.kwd17"></A> <A NAME="@manual.kwd18"></A> <A NAME="@manual.kwd19"></A> <A NAME="@manual.kwd20"></A> <A NAME="@manual.kwd21"></A> <A NAME="@manual.kwd22"></A> <A NAME="@manual.kwd23"></A> <A NAME="@manual.kwd24"></A> <A NAME="@manual.kwd25"></A> <A NAME="@manual.kwd26"></A> <A NAME="@manual.kwd27"></A> <A NAME="@manual.kwd28"></A> <A NAME="@manual.kwd29"></A> <A NAME="@manual.kwd30"></A><BR> <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>value-path</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>constant</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>begin</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>end</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>,</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>,</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> }</TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>ncconstr</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>`</FONT></TT><TT><I><FONT COLOR=maroon>tag-name</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>::</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>[</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> } <TT><FONT COLOR=blue>]</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>[|</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> } <TT><FONT COLOR=blue>|]</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>{</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> } <TT><FONT COLOR=blue>}</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>{</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> } <TT><FONT COLOR=blue>}</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><I><FONT COLOR=maroon>argument</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>prefix-symbol</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><I><FONT COLOR=maroon>infix-op</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>.(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>.(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>.[</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>]</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>.[</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>]</FONT></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>if</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>then</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> [ <TT><FONT COLOR=blue>else</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> ]</TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>while</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>do</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>done</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>for</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> ( <TT><FONT COLOR=blue>to</FONT></TT> | <TT><FONT COLOR=blue>downto</FONT></TT> ) <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>do</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>done</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>match</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> <TT><I><FONT COLOR=maroon>pattern-matching</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>function</FONT></TT> <TT><I><FONT COLOR=maroon>pattern-matching</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>multiple-matching</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>try</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> <TT><I><FONT COLOR=maroon>pattern-matching</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>let</FONT></TT> [<TT><FONT COLOR=blue>rec</FONT></TT>] <TT><I><FONT COLOR=maroon>let-binding</FONT></I></TT> { <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>let-binding</FONT></I></TT> } <TT><FONT COLOR=blue>in</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>new</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>method-name</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>:></FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>:></FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>{<</FONT></TT> <TT><I><FONT COLOR=maroon>inst-var-name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>inst-var-name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> } <TT><FONT COLOR=blue>>}</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>argument</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>~</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>~</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR></TABLE></DIV> <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>pattern-matching</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> [ <TT><FONT COLOR=blue>|</FONT></TT> ] <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT> [<TT><FONT COLOR=blue>when</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>] <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>|</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT> [<TT><FONT COLOR=blue>when</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>] <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> }</TD> </TR> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>multiple-matching</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> { <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP> [<TT><FONT COLOR=blue>when</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>] <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>let-binding</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT> [<TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>] <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT> { <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP> [<TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>] <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>~</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>~</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> [<TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>] <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>~</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> [<TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>] [<TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>] <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT> [<TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>] [<TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>] <TT><FONT COLOR=blue>)</FONT></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> <TT><I><FONT COLOR=maroon>infix-op</FONT></I></TT></TD> <TD ALIGN=right NOWRAP>::=</TD> <TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>infix-symbol</FONT></I></TT></TD> </TR> <TR><TD ALIGN=right NOWRAP> </TD> <TD ALIGN=right NOWRAP>|</TD> <TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>*</FONT></TT> | <TT><FONT COLOR=blue>=</FONT></TT> | <TT><FONT COLOR=blue>or</FONT></TT> | <TT><FONT COLOR=blue>&</FONT></TT></TD> </TR></TABLE></DIV><BR> The table below shows the relative precedences and associativity of operators and non-closed constructions. The constructions with higher precedence come first. For infix and prefix symbols, we write ``<TT>*</TT>...'' to mean ``any symbol starting with <TT>*</TT>''. <A NAME="@manual.kwd31"></A><A NAME="@manual.kwd32"></A><A NAME="@manual.kwd33"></A><A NAME="@manual.kwd34"></A><A NAME="@manual.kwd35"></A><A NAME="@manual.kwd36"></A><A NAME="@manual.kwd37"></A><A NAME="@manual.kwd38"></A><BR> <DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"> <TR><TD ALIGN=center NOWRAP><B>Construction or operator</B></TD> <TD ALIGN=center NOWRAP><B>Associativity</B></TD> </TR> <TR><TD ALIGN=left NOWRAP> prefix-symbol</TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>. .( .[</TT></TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP>function application</TD> <TD ALIGN=left NOWRAP>left</TD> </TR> <TR><TD ALIGN=left NOWRAP>constructor application</TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>- -.</TT> (prefix)</TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>**</TT>...</TD> <TD ALIGN=left NOWRAP>right</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>*</TT>...<TT> /</TT>...<TT> %</TT>...<TT> mod</TT></TD> <TD ALIGN=left NOWRAP>left</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>+</TT>...<TT> -</TT>...</TD> <TD ALIGN=left NOWRAP>left</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>::</TT></TD> <TD ALIGN=left NOWRAP>right</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>@</TT>...<TT>^</TT>...</TD> <TD ALIGN=left NOWRAP>right</TD> </TR> <TR><TD ALIGN=left NOWRAP>comparisons (<TT>= == < </TT> etc.), all other infix symbols</TD> <TD ALIGN=left NOWRAP>left</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>not</TT></TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>& &&</TT></TD> <TD ALIGN=left NOWRAP>left</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>or ||</TT></TD> <TD ALIGN=left NOWRAP>left</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>,</TT></TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT><- :=</TT></TD> <TD ALIGN=left NOWRAP>right</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>if</TT></TD> <TD ALIGN=left NOWRAP>--</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>;</TT></TD> <TD ALIGN=left NOWRAP>right</TD> </TR> <TR><TD ALIGN=left NOWRAP><TT>let match fun function try</TT></TD> <TD ALIGN=left NOWRAP>--</TD> </TR></TABLE></DIV><BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc66"><B><FONT SIZE=4>6.7.1</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Basic expressions</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Constants</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> Expressions consisting in a constant evaluate to this constant.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Value paths</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="expr:var"></A><BR> Expressions consisting in an access path evaluate to the value bound to this path in the current evaluation environment. The path can be either a value name or an access path to a value component of a module.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Parenthesized expressions</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="@manual.kwd39"></A> <A NAME="@manual.kwd40"></A><BR> The expressions <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> and <TT><FONT COLOR=blue>begin</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>end</FONT></TT> have the same value as <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>. Both constructs are semantically equivalent, but it is good style to use <TT><FONT COLOR=blue>begin</FONT></TT> ... <TT><FONT COLOR=blue>end</FONT></TT> inside control structures: <PRE> if ... then begin ... ; ... end else begin ... ; ... end </PRE> and <TT><FONT COLOR=blue>(</FONT></TT> ... <TT><FONT COLOR=blue>)</FONT></TT> for the other grouping situations.<BR> <BR> Parenthesized expressions can contain a type constraint, as in <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>type</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT>. This constraint forces the type of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> to be compatible with <TT><I><FONT COLOR=maroon>type</FONT></I></TT>.<BR> <BR> Parenthesized expressions can also contain coercions <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> [<TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>type</FONT></I></TT>] <TT><FONT COLOR=blue>:></FONT></TT> <TT><I><FONT COLOR=maroon>type</FONT></I></TT><TT><FONT COLOR=blue>)</FONT></TT> (see subsection <A HREF="#s:objects">6.7.5</A> below).<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Function application</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> Function application is denoted by juxtaposition of (possibly labeled) expressions. The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> evaluates the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> and those appearing in <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> must evaluate to a functional value <TT><I><FONT COLOR=maroon>f</FONT></I></TT>, which is then applied to the values of <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, ..., <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>.<BR> <BR> The order in which the expressions <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, ..., <TT><I><FONT COLOR=maroon>argument</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> are evaluated is not specified.<BR> <BR> Arguments and parameters are matched according to their respective labels. Argument order is irrelevant, except among arguments with the same label, or no label.<BR> <BR> If a parameter is specified as optional (label prefixed by <TT>?</TT>) in the type of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, the corresponding argument will be automatically wrapped with the constructor <TT>Some</TT>, except if the argument itself is also prefixed by <TT>?</TT>, in which case it is passed as is. If a non-labeled argument is passed, and its corresponding parameter is preceded by one or several optional parameters, then these parameters are <EM>defaulted</EM>, <EM>i.e.</EM> the value <TT>None</TT> will be passed for them. All other missing parameters (without corresponding argument), both optional and non-optional, will be kept, and the result of the function will still be a function of these missing parameters to the body of <TT><I><FONT COLOR=maroon>f</FONT></I></TT>.<BR> <BR> As a special case, if the function has a known arity, all the arguments are unlabeled, and their number matches the number of non-optional parameters, then labels are ignored and non-optional parameters are matched in their definition order. Optional arguments are defaulted.<BR> <BR> In all cases but exact match of order and labels, without optional parameters, the function type should be known at the application point. This can be ensured by adding a type constraint. Principality of the derivation can be checked in the <TT>-principal</TT> mode.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Function definition</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> Two syntactic forms are provided to define functions. The first form is introduced by the keyword <TT>function</TT>: <A NAME="@manual.kwd41"></A><BR> <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>function</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP>...</TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> </TR></TABLE></DIV> This expression evaluates to a functional value with one argument. When this function is applied to a value <I>v</I>, this value is matched against each pattern <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. If one of these matchings succeeds, that is, if the value <I>v</I> matches the pattern <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> for some <I>i</I>, then the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> associated to the selected pattern is evaluated, and its value becomes the value of the function application. The evaluation of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> takes place in an environment enriched by the bindings performed during the matching.<BR> <BR> If several patterns match the argument <I>v</I>, the one that occurs first in the function definition is selected. If none of the patterns matches the argument, the exception <TT>Match_failure</TT> is raised. <A NAME="@manual0"></A><BR> <BR> <BR> <BR> <BR> The other form of function definition is introduced by the keyword <TT>fun</TT>: <A NAME="@manual.kwd42"></A> <DIV ALIGN=center> <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> This expression is equivalent to: <DIV ALIGN=center> <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> ... <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> Functions of the form <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>optlabel</FONT></I></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>0</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> are equivalent to <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP> <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>optlabel</FONT></I></TT> <TT><I><FONT COLOR=maroon>x</FONT></I></TT> <TT><FONT COLOR=blue>-></FONT></TT> <TT><FONT COLOR=blue>let</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>match</FONT></TT> <TT><I><FONT COLOR=maroon>x</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> <TT><FONT COLOR=blue>Some</FONT></TT> <TT><I><FONT COLOR=maroon>x</FONT></I></TT> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>x</FONT></I></TT> <TT><FONT COLOR=blue>|</FONT></TT> <TT><FONT COLOR=blue>None</FONT></TT> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>0</FONT></SUB> <TT><FONT COLOR=blue>in</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT></TD> </TR></TABLE></DIV> where <TT><I><FONT COLOR=maroon>x</FONT></I></TT> is a fresh variable. When <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>0</FONT></SUB> will be evaluated is left unspecified.<BR> <BR> After these two transformations, expressions are of the form <DIV ALIGN=center> <TT><FONT COLOR=blue>fun</FONT></TT> [<TT><I><FONT COLOR=maroon>label</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>] <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> ... <TT><FONT COLOR=blue>fun</FONT></TT> [<TT><I><FONT COLOR=maroon>label</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>] <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> If we ignore labels, which will only be meaningful at function application, this is equivalent to <DIV ALIGN=center> <TT><FONT COLOR=blue>function</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> ... <TT><FONT COLOR=blue>function</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> That is, the <TT>fun</TT> expression above evaluates to a curried function with <I>n</I> arguments: after applying this function <I>n</I> times to the values <I>v</I><SUB><FONT SIZE=2>1</FONT></SUB> ... <I>v</I><SUB><FONT SIZE=2><I>m</I></FONT></SUB>, the values will be matched in parallel against the patterns <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. If the matching succeeds, the function returns the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> in an environment enriched by the bindings performed during the matchings. If the matching fails, the exception <TT>Match_failure</TT> is raised.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Guards in pattern-matchings</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> <A NAME="@manual.kwd43"></A> Cases of a pattern matching (in the <TT>function</TT>, <TT>fun</TT>, <TT>match</TT> and <TT>try</TT> constructs) can include guard expressions, which are arbitrary boolean expressions that must evaluate to <TT>true</TT> for the match case to be selected. Guards occur just before the <TT>-></TT> token and are introduced by the <TT>when</TT> keyword:<BR> <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>function</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB> [<TT><FONT COLOR=blue>when</FONT></TT> <I><FONT COLOR=maroon><I>cond</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB>]</TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP>...</TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB> [<TT><FONT COLOR=blue>when</FONT></TT> <I><FONT COLOR=maroon><I>cond</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB>]</TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> </TR></TABLE></DIV><BR> Matching proceeds as described before, except that if the value matches some pattern <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> which has a guard <TT><I><FONT COLOR=maroon>cond</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB>, then the expression <TT><I><FONT COLOR=maroon>cond</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> is evaluated (in an environment enriched by the bindings performed during matching). If <TT><I><FONT COLOR=maroon>cond</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> evaluates to <TT>true</TT>, then <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> is evaluated and its value returned as the result of the matching, as usual. But if <TT><I><FONT COLOR=maroon>cond</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> evaluates to <TT>false</TT>, the matching is resumed against the patterns following <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Local definitions</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="s:localdef"></A><BR> <A NAME="@manual.kwd44"></A><BR> The <TT>let</TT> and <TT>let rec</TT> constructs bind value names locally. The construct <DIV ALIGN=center> <TT><FONT COLOR=blue>let</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>and</FONT></TT> ... <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>in</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> evaluates <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> in some unspecified order, then matches their values against the patterns <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. If the matchings succeed, <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> is evaluated in the environment enriched by the bindings performed during matching, and the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> is returned as the value of the whole <TT>let</TT> expression. If one of the matchings fails, the exception <TT>Match_failure</TT> is raised. <A NAME="@manual1"></A><BR> <BR> An alternate syntax is provided to bind variables to functional values: instead of writing <DIV ALIGN=center> <TT><FONT COLOR=blue>let</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>fun</FONT></TT> <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2><I>m</I></FONT></SUB> <TT><FONT COLOR=blue>-></FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> in a <TT>let</TT> expression, one may instead write <DIV ALIGN=center> <TT><FONT COLOR=blue>let</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>parameter</FONT></I></TT><SUB><FONT SIZE=2><I>m</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV><BR> <BR> Recursive definitions of names are introduced by <TT>let rec</TT>: <DIV ALIGN=center> <TT><FONT COLOR=blue>let</FONT></TT> <TT><FONT COLOR=blue>rec</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>and</FONT></TT> ... <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>in</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> The only difference with the <TT>let</TT> construct described above is that the bindings of names to values performed by the pattern-matching are considered already performed when the expressions <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> are evaluated. That is, the expressions <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> can reference identifiers that are bound by one of the patterns <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, ..., <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>, and expect them to have the same value as in <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, the body of the <TT>let rec</TT> construct.<BR> <BR> The recursive definition is guaranteed to behave as described above if the expressions <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> are function definitions (<TT><FONT COLOR=blue>fun</FONT></TT> ... or <TT><FONT COLOR=blue>function</FONT></TT> ...), and the patterns <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> are just value names, as in: <DIV ALIGN=center> <TT><FONT COLOR=blue>let</FONT></TT> <TT><FONT COLOR=blue>rec</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>fun</FONT></TT> ... <TT><FONT COLOR=blue>and</FONT></TT> ... <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>fun</FONT></TT> ... <TT><FONT COLOR=blue>in</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> This defines <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> as mutually recursive functions local to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>. <BR> <BR> The behavior of other forms of <TT>let rec</TT> definitions is implementation-dependent. The current implementation also supports a certain class of recursive definitions of non-functional values, such as <DIV ALIGN=center> <TT><FONT COLOR=blue>let</FONT></TT> <TT><FONT COLOR=blue>rec</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>1</FONT></TT> <TT><FONT COLOR=blue>::</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>2</FONT></TT> <TT><FONT COLOR=blue>::</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>in</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> </DIV> which binds <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to the cyclic list <TT>1::2::1::2::</TT>..., and <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> to the cyclic list <TT>2::1::2::1::</TT>...Informally, the class of accepted definitions consists of those definitions where the defined names occur only inside function bodies or as argument to a data constructor.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc67"><B><FONT SIZE=4>6.7.2</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Control structures</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Sequence</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluates <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> first, then <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>, and returns the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Conditional</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="@manual.kwd45"></A><BR> The expression <TT><FONT COLOR=blue>if</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>then</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>else</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> evaluates to the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> if <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> evaluates to the boolean <TT><FONT COLOR=blue>true</FONT></TT>, and to the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> if <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> evaluates to the boolean <TT><FONT COLOR=blue>false</FONT></TT>.<BR> <BR> The <TT><FONT COLOR=blue>else</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> part can be omitted, in which case it defaults to <TT><FONT COLOR=blue>else</FONT></TT> <TT><FONT COLOR=blue>()</FONT></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Case expression</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><A NAME="@manual.kwd46"></A><BR> The expression <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>match</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I></TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>with</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP>...</TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> </TR></TABLE></DIV> matches the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> against the patterns <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. If the matching against <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> succeeds, the associated expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> is evaluated, and its value becomes the value of the whole <TT><FONT COLOR=blue>match</FONT></TT> expression. The evaluation of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> takes place in an environment enriched by the bindings performed during matching. If several patterns match the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, the one that occurs first in the <TT><FONT COLOR=blue>match</FONT></TT> expression is selected. If none of the patterns match the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, the exception <TT><FONT COLOR=blue>Match_failure</FONT></TT> is raised. <A NAME="@manual2"></A><BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Boolean operators</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>&&</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluates to <TT><FONT COLOR=blue>true</FONT></TT> if both <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> and <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluate to <TT><FONT COLOR=blue>true</FONT></TT>; otherwise, it evaluates to <TT><FONT COLOR=blue>false</FONT></TT>. The first component, <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, is evaluated first. The second component, <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>, is not evaluated if the first component evaluates to <TT><FONT COLOR=blue>false</FONT></TT>. Hence, the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>&&</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> behaves exactly as <DIV ALIGN=center> <TT><FONT COLOR=blue>if</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>then</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>else</FONT></TT> <TT><FONT COLOR=blue>false</FONT></TT>. </DIV><BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>||</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluates to <TT><FONT COLOR=blue>true</FONT></TT> if one of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> and <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluates to <TT><FONT COLOR=blue>true</FONT></TT>; otherwise, it evaluates to <TT><FONT COLOR=blue>false</FONT></TT>. The first component, <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, is evaluated first. The second component, <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>, is not evaluated if the first component evaluates to <TT><FONT COLOR=blue>true</FONT></TT>. Hence, the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>||</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> behaves exactly as <DIV ALIGN=center> <TT><FONT COLOR=blue>if</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>then</FONT></TT> <TT><FONT COLOR=blue>true</FONT></TT> <TT><FONT COLOR=blue>else</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>. </DIV><BR> <A NAME="@manual.kwd47"></A> The boolean operator <TT><FONT COLOR=blue>&</FONT></TT> is synonymous for <TT><FONT COLOR=blue>&&</FONT></TT>. The boolean operator <TT><FONT COLOR=blue>or</FONT></TT> is synonymous for <TT><FONT COLOR=blue>||</FONT></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Loops</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> <A NAME="@manual.kwd48"></A> The expression <TT><FONT COLOR=blue>while</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>do</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>done</FONT></TT> repeatedly evaluates <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> while <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> evaluates to <TT><FONT COLOR=blue>true</FONT></TT>. The loop condition <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> is evaluated and tested at the beginning of each iteration. The whole <TT><FONT COLOR=blue>while</FONT></TT> ... <TT><FONT COLOR=blue>done</FONT></TT> expression evaluates to the unit value <TT><FONT COLOR=blue>()</FONT></TT>.<BR> <BR> <A NAME="@manual.kwd49"></A> The expression <TT><FONT COLOR=blue>for</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>to</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>do</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> <TT><FONT COLOR=blue>done</FONT></TT> first evaluates the expressions <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> and <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> (the boundaries) into integer values <I>n</I> and <I>p</I>. Then, the loop body <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> is repeatedly evaluated in an environment where <TT><I><FONT COLOR=maroon>name</FONT></I></TT> is successively bound to the values <I>n</I>, <I>n</I>+1, ..., <I>p</I>-1, <I>p</I>. The loop body is never evaluated if <I>n</I> > <I>p</I>.<BR> <BR> The expression <TT><FONT COLOR=blue>for</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>downto</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>do</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> <TT><FONT COLOR=blue>done</FONT></TT> evaluates similarly, except that <TT><I><FONT COLOR=maroon>name</FONT></I></TT> is successively bound to the values <I>n</I>, <I>n</I>-1, ..., <I>p</I>+1, <I>p</I>. The loop body is never evaluated if <I>n</I> < <I>p</I>.<BR> <BR> In both cases, the whole <TT><FONT COLOR=blue>for</FONT></TT> expression evaluates to the unit value <TT><FONT COLOR=blue>()</FONT></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Exception handling</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="@manual.kwd50"></A><BR> The expression <DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>try </FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I></TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>with</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2>1</FONT></SUB></TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP>...</TD> </TR> <TR><TD ALIGN=right NOWRAP><TT><FONT COLOR=blue>|</FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>pattern</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> <TD ALIGN=left NOWRAP><TT><FONT COLOR=blue>-></FONT></TT></TD> <TD ALIGN=left NOWRAP><I><FONT COLOR=maroon><I>expr</I></FONT></I><SUB><FONT SIZE=2><I>n</I></FONT></SUB></TD> </TR></TABLE></DIV> evaluates the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> and returns its value if the evaluation of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> does not raise any exception. If the evaluation of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> raises an exception, the exception value is matched against the patterns <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. If the matching against <TT><I><FONT COLOR=maroon>pattern</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> succeeds, the associated expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> is evaluated, and its value becomes the value of the whole <TT><FONT COLOR=blue>try</FONT></TT> expression. The evaluation of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> takes place in an environment enriched by the bindings performed during matching. If several patterns match the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, the one that occurs first in the <TT><FONT COLOR=blue>try</FONT></TT> expression is selected. If none of the patterns matches the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, the exception value is raised again, thereby transparently ``passing through'' the <TT><FONT COLOR=blue>try</FONT></TT> construct.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc68"><B><FONT SIZE=4>6.7.3</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Operations on data structures</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Products</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>,</FONT></TT> ... <TT><FONT COLOR=blue>,</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> evaluates to the <I>n</I>-tuple of the values of expressions <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>. The evaluation order for the subexpressions is not specified.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Variants</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><I><FONT COLOR=maroon>ncconstr</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> evaluates to the variant value whose constructor is <TT><I><FONT COLOR=maroon>ncconstr</FONT></I></TT>, and whose argument is the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>.<BR> <BR> For lists, some syntactic sugar is provided. The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>::</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> stands for the constructor <TT><FONT COLOR=blue>(</FONT></TT> <TT><FONT COLOR=blue>::</FONT></TT> <TT><FONT COLOR=blue>)</FONT></TT> applied to the argument <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>,</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT>, and therefore evaluates to the list whose head is the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> and whose tail is the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>. The expression <TT><FONT COLOR=blue>[</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>;</FONT></TT> ... <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>]</FONT></TT> is equivalent to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>::</FONT></TT> ... <TT><FONT COLOR=blue>::</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>::</FONT></TT> <TT><FONT COLOR=blue>[]</FONT></TT>, and therefore evaluates to the list whose elements are the values of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Polymorphic variants</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><FONT COLOR=blue>`</FONT></TT><TT><I><FONT COLOR=maroon>tag-name</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> evaluates to the variant value whose tag is <TT><I><FONT COLOR=maroon>tag-name</FONT></I></TT>, and whose argument is the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Records</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><FONT COLOR=blue>{</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>;</FONT></TT> ... <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>}</FONT></TT> evaluates to the record value <TT><FONT COLOR=blue>{</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>v</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>;</FONT></TT> ... <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>v</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>}</FONT></TT>, where <TT><I><FONT COLOR=maroon>v</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> is the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>i</I></FONT></SUB> for <I>i</I> = 1,... , <I>n</I>. The fields <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> must all belong to the same record types; all fields belonging to this record type must appear exactly once in the record expression, though they can appear in any order. The order in which <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> are evaluated is not specified.<BR> <BR> The expression <TT><FONT COLOR=blue>{</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>;</FONT></TT> ... <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>}</FONT></TT> builds a fresh record with fields <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> equal to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>, and all other fields having the same value as in the record <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>. In other terms, it returns a shallow copy of the record <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>, except for the fields <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>field</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>, which are initialized to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>.<BR> <BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> evaluates <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to a record value, and returns the value associated to <TT><I><FONT COLOR=maroon>field</FONT></I></TT> in this record value.<BR> <BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluates <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to a record value, which is then modified in-place by replacing the value associated to <TT><I><FONT COLOR=maroon>field</FONT></I></TT> in this record by the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>. This operation is permitted only if <TT><I><FONT COLOR=maroon>field</FONT></I></TT> has been declared <TT><FONT COLOR=blue>mutable</FONT></TT> in the definition of the record type. The whole expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.</FONT></TT> <TT><I><FONT COLOR=maroon>field</FONT></I></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> evaluates to the unit value <TT><FONT COLOR=blue>()</FONT></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Arrays</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><FONT COLOR=blue>[|</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>;</FONT></TT> ... <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>|]</FONT></TT> evaluates to a <I>n</I>-element array, whose elements are initialized with the values of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> respectively. The order in which these expressions are evaluated is unspecified.<BR> <BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT> returns the value of element number <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> in the array denoted by <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>. The first element has number 0; the last element has number <I>n</I>-1, where <I>n</I> is the size of the array. The exception <TT>Invalid_argument</TT> is raised if the access is out of bounds.<BR> <BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> modifies in-place the array denoted by <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, replacing element number <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> by the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB>. The exception <TT>Invalid_argument</TT> is raised if the access is out of bounds. The value of the whole expression is <TT><FONT COLOR=blue>()</FONT></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Strings</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.[</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>]</FONT></TT> returns the value of character number <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> in the string denoted by <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>. The first character has number 0; the last character has number <I>n</I>-1, where <I>n</I> is the length of the string. The exception <TT>Invalid_argument</TT> is raised if the access is out of bounds.<BR> <BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.[</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>]</FONT></TT> <TT><FONT COLOR=blue><-</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB> modifies in-place the string denoted by <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, replacing character number <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> by the value of <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>3</FONT></SUB>. The exception <TT>Invalid_argument</TT> is raised if the access is out of bounds. The value of the whole expression is <TT><FONT COLOR=blue>()</FONT></TT>.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc69"><B><FONT SIZE=4>6.7.4</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Operators</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> Symbols from the class <TT><FONT COLOR=blue>infix-symbols</FONT></TT>, as well as the keywords <TT>*</TT>, <TT>=</TT>, <TT>or</TT> and <TT>&</TT>, can appear in infix position (between two expressions). Symbols from the class <TT><FONT COLOR=blue>prefix-symbols</FONT></TT> can appear in prefix position (in front of an expression).<BR> <BR> Infix and prefix symbols do not have a fixed meaning: they are simply interpreted as applications of functions bound to the names corresponding to the symbols. The expression <TT><I><FONT COLOR=maroon>prefix-symbol</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> is interpreted as the application <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>prefix-symbol</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>. Similarly, the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><I><FONT COLOR=maroon>infix-symbol</FONT></I></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> is interpreted as the application <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>infix-symbol</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>.<BR> <BR> The table below lists the symbols defined in the initial environment and their initial meaning. (See the description of the standard library module <TT>Pervasive</TT> in chapter <A HREF="manual034.html#c:stdlib">20</A> for more details). Their meaning may be changed at any time using <TT><FONT COLOR=blue>let</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>infix-op</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>=</FONT></TT> ...<BR> <DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"> <TR><TD ALIGN=center NOWRAP><B>Operator</B></TD> <TD ALIGN=center NOWRAP><B>Initial meaning</B></TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP> <TT>+</TT></TD> <TD VALIGN=top ALIGN=left>Integer addition.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>-</TT> (infix)</TD> <TD VALIGN=top ALIGN=left>Integer subtraction.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>-</TT> (prefix)</TD> <TD VALIGN=top ALIGN=left>Integer negation.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>*</TT></TD> <TD VALIGN=top ALIGN=left>Integer multiplication.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>/</TT></TD> <TD VALIGN=top ALIGN=left>Integer division. Raise <TT>Division_by_zero</TT> if second argument is zero. The result is unspecified if either argument is negative.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>mod</TT></TD> <TD VALIGN=top ALIGN=left>Integer modulus. Raise <TT>Division_by_zero</TT> if second argument is zero. The result is unspecified if either argument is negative.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>land</TT></TD> <TD VALIGN=top ALIGN=left>Bitwise logical ``and'' on integers.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lor</TT></TD> <TD VALIGN=top ALIGN=left>Bitwise logical ``or'' on integers.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lxor</TT></TD> <TD VALIGN=top ALIGN=left>Bitwise logical ``exclusive or'' on integers.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lsl</TT></TD> <TD VALIGN=top ALIGN=left>Bitwise logical shift left on integers.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lsr</TT></TD> <TD VALIGN=top ALIGN=left>Bitwise logical shift right on integers.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>asr</TT></TD> <TD VALIGN=top ALIGN=left>Bitwise arithmetic shift right on integers.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>+.</TT></TD> <TD VALIGN=top ALIGN=left>Floating-point addition.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>-.</TT> (infix)</TD> <TD VALIGN=top ALIGN=left>Floating-point subtraction.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>-.</TT> (prefix)</TD> <TD VALIGN=top ALIGN=left>Floating-point negation.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>*.</TT></TD> <TD VALIGN=top ALIGN=left>Floating-point multiplication.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>/.</TT></TD> <TD VALIGN=top ALIGN=left>Floating-point division.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>**</TT></TD> <TD VALIGN=top ALIGN=left>Floating-point exponentiation.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>@</TT> </TD> <TD VALIGN=top ALIGN=left>List concatenation.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>^</TT> </TD> <TD VALIGN=top ALIGN=left>String concatenation.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>!</TT> </TD> <TD VALIGN=top ALIGN=left>Dereferencing (return the current contents of a reference).</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>:=</TT></TD> <TD VALIGN=top ALIGN=left>Reference assignment (update the reference given as first argument with the value of the second argument).</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>=</TT> </TD> <TD VALIGN=top ALIGN=left>Structural equality test.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT><></TT> </TD> <TD VALIGN=top ALIGN=left>Structural inequality test.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>==</TT> </TD> <TD VALIGN=top ALIGN=left>Physical equality test.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>!=</TT> </TD> <TD VALIGN=top ALIGN=left>Physical inequality test.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT><</TT> </TD> <TD VALIGN=top ALIGN=left>Test ``less than''.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT><=</TT> </TD> <TD VALIGN=top ALIGN=left>Test ``less than or equal''.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>></TT> </TD> <TD VALIGN=top ALIGN=left>Test ``greater than''.</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>>=</TT> </TD> <TD VALIGN=top ALIGN=left>Test ``greater than or equal''.</TD> </TR></TABLE></DIV><BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc70"><B><FONT SIZE=4>6.7.5</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Objects</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="s:objects"></A><BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Object creation</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> <A NAME="@manual.kwd51"></A><BR> When <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> evaluates to a class body, <TT><FONT COLOR=blue>new</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> evaluates to an object containing the instance variables and methods of this class.<BR> <BR> When <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> evaluates to a class function, <TT><FONT COLOR=blue>new</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> evaluates to a function expecting the same number of arguments and returning a new object of this class.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Message sending</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>method-name</FONT></I></TT> invokes the method <TT><I><FONT COLOR=maroon>method-name</FONT></I></TT> of the object denoted by <TT><I><FONT COLOR=maroon>expr</FONT></I></TT>.<BR> <BR> If <TT><I><FONT COLOR=maroon>method-name</FONT></I></TT> is a polymorphic method, its type should be known at the invocation site. This is true for instance if <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> is the name of a fresh object (<TT><FONT COLOR=blue>let</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> = <TT><FONT COLOR=blue>new</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> ... ) or if there is a type constraint. Principality of the derivation can be checked in the <TT>-principal</TT> mode.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Coercion</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> The type of an object can be coerced (weakened) to a supertype. The expression <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>:></FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> coerces the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> to type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>. The expression <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>:></FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT> coerces the expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> from type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>. The former operator will sometimes fail to coerce an expression <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> from a type <TT><I><FONT COLOR=maroon>t</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to a type <TT><I><FONT COLOR=maroon>t</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> even if type <TT><I><FONT COLOR=maroon>t</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> is a subtype of type <TT><I><FONT COLOR=maroon>t</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>: in the current implementation it only expands two levels of type abbreviations containing objects and/or variants, keeping only recursion when it is explicit in the class type. In case of failure, the latter operator should be used.<BR> <BR> In a class definition, coercion to the type this class defines is the identity, as this type abbreviation is not yet completely defined.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE> <TR><TD><B>Object duplication</B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> An object can be duplicated using the library function <TT>Oo.copy</TT> (see <a HREF=libref/Oo.html>Module <tt>Oo</tt></a> ). Inside a method, the expression <TT><FONT COLOR=blue>{<</FONT></TT> <TT><I><FONT COLOR=maroon>inst-var-name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> { <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>inst-var-name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>expr</FONT></I></TT> } <TT><FONT COLOR=blue>>}</FONT></TT> returns a copy of self with the given instance variables replaced by the values of the associated expressions; other instance variables have the same value in the returned object as in self.<BR> <BR> <BR> <BR> <HR> <A HREF="manual014.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual016.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> </BODY> </HTML>