36
23
<A NAME="@manual.kwd64"></A>
37
24
<A NAME="@manual.kwd65"></A>
38
25
<A NAME="@manual.kwd66"></A>
39
<A NAME="@manual.kwd67"></A><BR>
41
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
42
<TR><TD ALIGN=right NOWRAP>
43
<A NAME="class-type"></A>
44
<FONT COLOR=maroon><I><TT>class-type</TT></I></FONT></TD>
45
<TD ALIGN=right NOWRAP>::=</TD>
46
<TD ALIGN=left NOWRAP>
47
<FONT COLOR=maroon><I><a href="#class-body-type"><font color=maroon><TT>class-body-type</TT></font></a></I></FONT></TD>
49
<TR><TD ALIGN=right NOWRAP> </TD>
50
<TD ALIGN=right NOWRAP>∣</TD>
51
<TD ALIGN=left NOWRAP> [[<FONT COLOR=blue><TT>?</TT></FONT>]<TT><FONT COLOR=maroon><a href="manual011.html#label-name"><font color=maroon><I>label-name</I></font></a></FONT><FONT COLOR=blue>:</FONT></TT>] <FONT COLOR=maroon><TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>-></TT></FONT> <TT><a href="#class-type"><font color=maroon><I>class-type</I></font></a></TT></FONT></TD>
53
<TR><TD ALIGN=right NOWRAP>
54
<A NAME="class-body-type"></A>
55
<FONT COLOR=maroon><I><TT>class-body-type</TT></I></FONT></TD>
56
<TD ALIGN=right NOWRAP>::=</TD>
57
<TD ALIGN=left NOWRAP>
58
<FONT COLOR=blue><TT>object</TT></FONT> [<FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT> <TT>)</TT></FONT>] {<FONT COLOR=maroon><I><a href="#class-field-spec"><font color=maroon><TT>class-field-spec</TT></font></a></I></FONT>} <FONT COLOR=blue><TT>end</TT></FONT></TD>
60
<TR><TD ALIGN=right NOWRAP> </TD>
61
<TD ALIGN=right NOWRAP>∣</TD>
62
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
64
<TR><TD ALIGN=right NOWRAP> </TD>
65
<TD ALIGN=right NOWRAP>∣</TD>
66
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>[</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> {<FONT COLOR=blue><TT>,</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT>} <FONT COLOR=blue><TT>]</TT></FONT> <FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
68
<TR><TD ALIGN=right NOWRAP>
69
<A NAME="class-field-spec"></A>
70
<FONT COLOR=maroon><I><TT>class-field-spec</TT></I></FONT></TD>
71
<TD ALIGN=right NOWRAP>::=</TD>
72
<TD ALIGN=left NOWRAP>
73
<FONT COLOR=blue><TT>inherit</TT></FONT> <FONT COLOR=maroon><I><a href="#class-type"><font color=maroon><TT>class-type</TT></font></a></I></FONT></TD>
75
<TR><TD ALIGN=right NOWRAP> </TD>
76
<TD ALIGN=right NOWRAP>∣</TD>
77
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>val</TT></FONT> [<FONT COLOR=blue><TT>mutable</TT></FONT>] <FONT COLOR=maroon><TT><a href="manual011.html#inst-var-name"><font color=maroon><I>inst-var-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT></TD>
79
<TR><TD ALIGN=right NOWRAP> </TD>
80
<TD ALIGN=right NOWRAP>∣</TD>
81
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=maroon><TT><a href="manual011.html#method-name"><font color=maroon><I>method-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="manual012.html#poly-typexpr"><font color=maroon><I>poly-typexpr</I></font></a></TT></FONT></TD>
83
<TR><TD ALIGN=right NOWRAP> </TD>
84
<TD ALIGN=right NOWRAP>∣</TD>
85
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=blue><TT>virtual</TT></FONT> <FONT COLOR=maroon><TT><a href="manual011.html#method-name"><font color=maroon><I>method-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="manual012.html#poly-typexpr"><font color=maroon><I>poly-typexpr</I></font></a></TT></FONT></TD>
87
<TR><TD ALIGN=right NOWRAP> </TD>
88
<TD ALIGN=right NOWRAP>∣</TD>
89
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>constraint</TT></FONT> <FONT COLOR=maroon><TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT></TD>
90
</TR></TABLE></DIV><BR>
93
<H4 CLASS="subsubsection">Simple class expressions</H4>
94
The expression <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT> is equivalent to the class type bound to
95
the name <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT>. Similarly, the expression
96
<FONT COLOR=blue><TT>[</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>,</TT></FONT> … <I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I> <FONT COLOR=blue><TT>]</TT></FONT> <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT> is equivalent to
97
the parametric class type bound to the name <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT>, in which
98
type parameters have been instanciated to respectively <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB>,
99
...<I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I>.<BR>
102
<H4 CLASS="subsubsection">Class function type</H4>
103
The class type expression <FONT COLOR=maroon><TT><I>typexpr</I></TT> <FONT COLOR=blue><TT>-></TT></FONT> <TT><I>class-type</I></TT></FONT> is the type of
26
<A NAME="@manual.kwd67"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
27
<I><A NAME="class-type"><FONT COLOR=maroon>class-type</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
28
<I><A HREF="#class-body-type"><FONT COLOR=maroon>class-body-type</FONT></A></I>
30
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��[[<FONT COLOR=blue><TT>?</TT></FONT>]<I><A HREF="manual011.html#label-name"><FONT COLOR=maroon>label-name</FONT></A></I><FONT COLOR=blue><TT>:</TT></FONT>]��<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>-></TT></FONT>��<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>
32
<TR><TD ALIGN=right NOWRAP> </TD></TR>
33
<TR><TD ALIGN=right NOWRAP>
34
<I><A NAME="class-body-type"><FONT COLOR=maroon>class-body-type</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
35
<FONT COLOR=blue><TT>object</TT></FONT>�[<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>)</TT></FONT>]��{<I><A HREF="#class-field-spec"><FONT COLOR=maroon>class-field-spec</FONT></A></I>}�<FONT COLOR=blue><TT>end</TT></FONT>
37
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
39
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>[</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>��{<FONT COLOR=blue><TT>,</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>}�<FONT COLOR=blue><TT>]</TT></FONT>��<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
41
<TR><TD ALIGN=right NOWRAP> </TD></TR>
42
<TR><TD ALIGN=right NOWRAP>
43
<I><A NAME="class-field-spec"><FONT COLOR=maroon>class-field-spec</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
44
<FONT COLOR=blue><TT>inherit</TT></FONT>�<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>
46
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>val</TT></FONT>�[<FONT COLOR=blue><TT>mutable</TT></FONT>]�[<FONT COLOR=blue><TT>virtual</TT></FONT>]�<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
48
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>method</TT></FONT>�[<FONT COLOR=blue><TT>private</TT></FONT>]�<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="manual012.html#poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I>
50
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>method</TT></FONT>�[<FONT COLOR=blue><TT>private</TT></FONT>]�<FONT COLOR=blue><TT>virtual</TT></FONT>�<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="manual012.html#poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I>
52
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>constraint</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
54
<TR><TD ALIGN=right NOWRAP> </TD></TR>
56
</TABLE><H4 CLASS="subsubsection">Simple class expressions</H4><P>The expression <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> is equivalent to the class type bound to
57
the name <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>. Similarly, the expression
58
<FONT COLOR=blue><TT>[</TT></FONT> <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>,</TT></FONT> … �<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I> <FONT COLOR=blue><TT>]</TT></FONT> �<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> is equivalent to
59
the parametric class type bound to the name <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>, in which
60
type parameters have been instanciated to respectively <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB>,
61
…<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I>.</P><H4 CLASS="subsubsection">Class function type</H4><P>The class type expression <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I> is the type of
104
62
class functions (functions from values to classes) that take as
105
argument a value of type <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT> and return as result a class of
106
type <FONT COLOR=maroon><I><TT>class-type</TT></I></FONT>.<BR>
109
<H4 CLASS="subsubsection">Class body type</H4>
110
The class type expression
111
<FONT COLOR=blue><TT>object</TT></FONT> [<FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><I>typexpr</I></TT></FONT> <TT>)</TT></FONT>] {<FONT COLOR=maroon><I><TT>class-field-spec</TT></I></FONT>} <FONT COLOR=blue><TT>end</TT></FONT>
63
argument a value of type <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> and return as result a class of
64
type <I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>.</P><H4 CLASS="subsubsection">Class body type</H4><P>The class type expression
65
<FONT COLOR=blue><TT>object</TT></FONT> [<FONT COLOR=blue><TT>(</TT></FONT> <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> <FONT COLOR=blue><TT>)</TT></FONT>] �{<I><A HREF="#class-field-spec"><FONT COLOR=maroon>class-field-spec</FONT></A></I>} <FONT COLOR=blue><TT>end</TT></FONT>
112
66
is the type of a class body. It specifies its instance variables and
113
methods. In this type, <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT> is matched against the self type, therefore
114
providing a binding for the self type.<BR>
116
A class body will match a class body type if it provides definitions
67
methods. In this type, <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> is matched against the self type, therefore
68
providing a binding for the self type.</P><P>A class body will match a class body type if it provides definitions
117
69
for all the components specified in the class type, and these
118
70
definitions meet the type requirements given in the class type.
119
71
Furthermore, all methods either virtual or public present in the class
202
120
<A NAME="@manual.kwd89"></A>
203
121
<A NAME="@manual.kwd90"></A>
204
122
<A NAME="@manual.kwd91"></A>
205
<A NAME="@manual.kwd92"></A><BR>
207
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
208
<TR><TD ALIGN=right NOWRAP>
209
<A NAME="class-expr"></A>
210
<FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT></TD>
211
<TD ALIGN=right NOWRAP>::=</TD>
212
<TD ALIGN=left NOWRAP>
213
<FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
215
<TR><TD ALIGN=right NOWRAP> </TD>
216
<TD ALIGN=right NOWRAP>∣</TD>
217
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>[</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> {<FONT COLOR=blue><TT>,</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT>} <FONT COLOR=blue><TT>]</TT></FONT> <FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
219
<TR><TD ALIGN=right NOWRAP> </TD>
220
<TD ALIGN=right NOWRAP>∣</TD>
221
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><a href="#class-expr"><font color=maroon><I>class-expr</I></font></a></TT></FONT> <TT>)</TT></FONT></TD>
223
<TR><TD ALIGN=right NOWRAP> </TD>
224
<TD ALIGN=right NOWRAP>∣</TD>
225
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><a href="#class-expr"><font color=maroon><I>class-expr</I></font></a></TT></FONT> <TT>:</TT> <FONT COLOR=maroon><TT><a href="#class-type"><font color=maroon><I>class-type</I></font></a></TT></FONT> <TT>)</TT></FONT></TD>
227
<TR><TD ALIGN=right NOWRAP> </TD>
228
<TD ALIGN=right NOWRAP>∣</TD>
229
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#class-expr"><font color=maroon><TT>class-expr</TT></font></a></I></FONT> {<FONT COLOR=maroon><I><a href="manual015.html#argument"><font color=maroon><TT>argument</TT></font></a></I></FONT>}<SUP>+</SUP></TD>
231
<TR><TD ALIGN=right NOWRAP> </TD>
232
<TD ALIGN=right NOWRAP>∣</TD>
233
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>fun</TT></FONT> {<FONT COLOR=maroon><I><a href="manual015.html#parameter"><font color=maroon><TT>parameter</TT></font></a></I></FONT>}<SUP>+</SUP> <FONT COLOR=blue><TT>-></TT></FONT> <FONT COLOR=maroon><I><a href="#class-expr"><font color=maroon><TT>class-expr</TT></font></a></I></FONT></TD>
235
<TR><TD ALIGN=right NOWRAP> </TD>
236
<TD ALIGN=right NOWRAP>∣</TD>
237
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>let</TT></FONT> [<FONT COLOR=blue><TT>rec</TT></FONT>] <FONT COLOR=maroon><I><a href="manual015.html#let-binding"><font color=maroon><TT>let-binding</TT></font></a></I></FONT> {<FONT COLOR=blue><TT>and</TT></FONT> <FONT COLOR=maroon><I><a href="manual015.html#let-binding"><font color=maroon><TT>let-binding</TT></font></a></I></FONT>} <FONT COLOR=blue><TT>in</TT></FONT> <FONT COLOR=maroon><I><a href="#class-expr"><font color=maroon><TT>class-expr</TT></font></a></I></FONT></TD>
239
<TR><TD ALIGN=right NOWRAP> </TD>
240
<TD ALIGN=right NOWRAP>∣</TD>
241
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>object</TT></FONT> [<FONT COLOR=blue><TT>(</TT></FONT> <FONT COLOR=maroon><I><a href="manual014.html#pattern"><font color=maroon><TT>pattern</TT></font></a></I></FONT> [<FONT COLOR=blue><TT>:</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT>] <FONT COLOR=blue><TT>)</TT></FONT>] { <FONT COLOR=maroon><I><a href="#class-field"><font color=maroon><TT>class-field</TT></font></a></I></FONT> } <FONT COLOR=blue><TT>end</TT></FONT></TD>
243
<TR><TD ALIGN=right NOWRAP>
244
<A NAME="class-field"></A>
245
<FONT COLOR=maroon><I><TT>class-field</TT></I></FONT></TD>
246
<TD ALIGN=right NOWRAP>::=</TD>
247
<TD ALIGN=left NOWRAP>
248
<FONT COLOR=blue><TT>inherit</TT></FONT> <FONT COLOR=maroon><I><a href="#class-expr"><font color=maroon><TT>class-expr</TT></font></a></I></FONT> [<FONT COLOR=blue><TT>as</TT></FONT> <FONT COLOR=maroon><I><a href="manual011.html#value-name"><font color=maroon><TT>value-name</TT></font></a></I></FONT>]</TD>
250
<TR><TD ALIGN=right NOWRAP> </TD>
251
<TD ALIGN=right NOWRAP>∣</TD>
252
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>val</TT></FONT> [<FONT COLOR=blue><TT>mutable</TT></FONT>] <FONT COLOR=maroon><I><a href="manual011.html#inst-var-name"><font color=maroon><TT>inst-var-name</TT></font></a></I></FONT> [<FONT COLOR=blue><TT>:</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT>] <FONT COLOR=blue><TT>=</TT></FONT> <FONT COLOR=maroon><I><a href="manual015.html#expr"><font color=maroon><TT>expr</TT></font></a></I></FONT></TD>
254
<TR><TD ALIGN=right NOWRAP> </TD>
255
<TD ALIGN=right NOWRAP>∣</TD>
256
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=maroon><I><a href="manual011.html#method-name"><font color=maroon><TT>method-name</TT></font></a></I></FONT> {<FONT COLOR=maroon><I><a href="manual015.html#parameter"><font color=maroon><TT>parameter</TT></font></a></I></FONT>} [<FONT COLOR=blue><TT>:</TT></FONT> <FONT COLOR=maroon><I><a href="manual012.html#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT>] <FONT COLOR=blue><TT>=</TT></FONT> <FONT COLOR=maroon><I><a href="manual015.html#expr"><font color=maroon><TT>expr</TT></font></a></I></FONT></TD>
258
<TR><TD ALIGN=right NOWRAP> </TD>
259
<TD ALIGN=right NOWRAP>∣</TD>
260
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=maroon><TT><a href="manual011.html#method-name"><font color=maroon><I>method-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="manual012.html#poly-typexpr"><font color=maroon><I>poly-typexpr</I></font></a></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><a href="manual015.html#expr"><font color=maroon><I>expr</I></font></a></TT></FONT></TD>
262
<TR><TD ALIGN=right NOWRAP> </TD>
263
<TD ALIGN=right NOWRAP>∣</TD>
264
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=blue><TT>virtual</TT></FONT> <FONT COLOR=maroon><TT><a href="manual011.html#method-name"><font color=maroon><I>method-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="manual012.html#poly-typexpr"><font color=maroon><I>poly-typexpr</I></font></a></TT></FONT></TD>
266
<TR><TD ALIGN=right NOWRAP> </TD>
267
<TD ALIGN=right NOWRAP>∣</TD>
268
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>constraint</TT></FONT> <FONT COLOR=maroon><TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><a href="manual012.html#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT></TD>
270
<TR><TD ALIGN=right NOWRAP> </TD>
271
<TD ALIGN=right NOWRAP>∣</TD>
272
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>initializer</TT></FONT> <FONT COLOR=maroon><I><a href="manual015.html#expr"><font color=maroon><TT>expr</TT></font></a></I></FONT></TD>
273
</TR></TABLE></DIV><BR>
276
<H4 CLASS="subsubsection">Simple class expressions</H4>
277
The expression <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT> evaluates to the class bound to the name
278
<FONT COLOR=maroon><I><TT>class-path</TT></I></FONT>. Similarly, the expression
279
<FONT COLOR=blue><TT>[</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>,</TT></FONT> … <I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I> <FONT COLOR=blue><TT>]</TT></FONT> <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT>
280
evaluates to the parametric class bound to the name <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT>,
123
<A NAME="@manual.kwd92"></A>
124
<A NAME="@manual.kwd93"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
125
<I><A NAME="class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
126
<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
128
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>[</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>��{<FONT COLOR=blue><TT>,</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>}�<FONT COLOR=blue><TT>]</TT></FONT>��<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
130
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>�<FONT COLOR=blue><TT>)</TT></FONT>
132
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>�<FONT COLOR=blue><TT>)</TT></FONT>
134
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>��{<I><A HREF="expr.html#argument"><FONT COLOR=maroon>argument</FONT></A></I>}<SUP>+</SUP>
136
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>fun</TT></FONT>�{<I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A></I>}<SUP>+</SUP>�<FONT COLOR=blue><TT>-></TT></FONT>��<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>
138
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>let</TT></FONT>�[<FONT COLOR=blue><TT>rec</TT></FONT>]�<I><A HREF="expr.html#let-binding"><FONT COLOR=maroon>let-binding</FONT></A></I>��{<FONT COLOR=blue><TT>and</TT></FONT>�<I><A HREF="expr.html#let-binding"><FONT COLOR=maroon>let-binding</FONT></A></I>}�<FONT COLOR=blue><TT>in</TT></FONT>��<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>
140
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>object</TT></FONT>�[<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="patterns.html#pattern"><FONT COLOR=maroon>pattern</FONT></A></I>��[<FONT COLOR=blue><TT>:</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>]�<FONT COLOR=blue><TT>)</TT></FONT>]��{�<I><A HREF="#class-field"><FONT COLOR=maroon>class-field</FONT></A></I>�}�<FONT COLOR=blue><TT>end</TT></FONT>
142
<TR><TD ALIGN=right NOWRAP> </TD></TR>
143
<TR><TD ALIGN=right NOWRAP>
144
<I><A NAME="class-field"><FONT COLOR=maroon>class-field</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
145
<FONT COLOR=blue><TT>inherit</TT></FONT>�<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>��[<FONT COLOR=blue><TT>as</TT></FONT>�<I><A HREF="manual011.html#value-name"><FONT COLOR=maroon>value-name</FONT></A></I>]
147
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>val</TT></FONT>�[<FONT COLOR=blue><TT>mutable</TT></FONT>]�<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I>��[<FONT COLOR=blue><TT>:</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>]�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>
149
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>val</TT></FONT>�[<FONT COLOR=blue><TT>mutable</TT></FONT>]�<FONT COLOR=blue><TT>virtual</TT></FONT>�<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
151
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>method</TT></FONT>�[<FONT COLOR=blue><TT>private</TT></FONT>]�<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>��{<I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A></I>}��[<FONT COLOR=blue><TT>:</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>]�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>
153
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>method</TT></FONT>�[<FONT COLOR=blue><TT>private</TT></FONT>]�<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="manual012.html#poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I>�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>
155
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>method</TT></FONT>�[<FONT COLOR=blue><TT>private</TT></FONT>]�<FONT COLOR=blue><TT>virtual</TT></FONT>�<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="manual012.html#poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I>
157
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>constraint</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
159
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>��<FONT COLOR=blue><TT>initializer</TT></FONT>�<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>
161
<TR><TD ALIGN=right NOWRAP> </TD></TR>
163
</TABLE><H4 CLASS="subsubsection">Simple class expressions</H4><P>The expression <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> evaluates to the class bound to the name
164
<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>. Similarly, the expression
165
<FONT COLOR=blue><TT>[</TT></FONT> <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>,</TT></FONT> … �<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I> <FONT COLOR=blue><TT>]</TT></FONT> �<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
166
evaluates to the parametric class bound to the name <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>,
281
167
in which type parameters have been instanciated to respectively
282
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB>, ...<I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I>.<BR>
284
The expression <FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><I>class-expr</I></TT></FONT> <TT>)</TT></FONT> evaluates to the same module as
285
<FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT>.<BR>
287
The expression <FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><I>class-expr</I></TT></FONT> <TT>:</TT> <FONT COLOR=maroon><TT><I>class-type</I></TT></FONT> <TT>)</TT></FONT> checks that
288
<FONT COLOR=maroon><I><TT>class-type</TT></I></FONT> match the type of <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT> (that is, that the
289
implementation <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT> meets the type specification
290
<FONT COLOR=maroon><I><TT>class-type</TT></I></FONT>). The whole expression evaluates to the same class as
291
<FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT>, except that all components not specified in
292
<FONT COLOR=maroon><I><TT>class-type</TT></I></FONT> are hidden and can no longer be accessed.<BR>
295
<H4 CLASS="subsubsection">Class application</H4>
296
Class application is denoted by juxtaposition of (possibly labeled)
297
expressions. Evaluation works as for expression application.<BR>
300
<H4 CLASS="subsubsection">Class function</H4>
301
The expression <FONT COLOR=blue><TT>fun</TT></FONT> [[<FONT COLOR=blue><TT>?</TT></FONT>]<TT><FONT COLOR=maroon><I>label-name</I></FONT><FONT COLOR=blue>:</FONT></TT>] <FONT COLOR=maroon><TT><I>pattern</I></TT> <FONT COLOR=blue><TT>-></TT></FONT> <TT><I>class-expr</I></TT></FONT> evaluates
168
<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB>, …<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I>.</P><P>The expression <FONT COLOR=blue><TT>(</TT></FONT> <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> <FONT COLOR=blue><TT>)</TT></FONT> evaluates to the same module as
169
<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>.</P><P>The expression <FONT COLOR=blue><TT>(</TT></FONT> <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> <FONT COLOR=blue><TT>:</TT></FONT> �<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I> <FONT COLOR=blue><TT>)</TT></FONT> checks that
170
<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I> match the type of <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> (that is, that the
171
implementation <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> meets the type specification
172
<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>). The whole expression evaluates to the same class as
173
<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>, except that all components not specified in
174
<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I> are hidden and can no longer be accessed.</P><H4 CLASS="subsubsection">Class application</H4><P>Class application is denoted by juxtaposition of (possibly labeled)
175
expressions. Evaluation works as for expression application.</P><H4 CLASS="subsubsection">Class function</H4><P>The expression <FONT COLOR=blue><TT>fun</TT></FONT> [[<FONT COLOR=blue><TT>?</TT></FONT>]<I><A HREF="manual011.html#label-name"><FONT COLOR=maroon>label-name</FONT></A></I><FONT COLOR=blue><TT>:</TT></FONT>]�<I><A HREF="patterns.html#pattern"><FONT COLOR=maroon>pattern</FONT></A></I> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> evaluates
302
176
to a function from values to classes.
303
177
When this function is applied to a value <I>v</I>, this value is
304
matched against the pattern <FONT COLOR=maroon><I><TT>pattern</TT></I></FONT> and the result is the result of
305
the evaluation of <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT> in the extended environment.<BR>
307
Conversion from functions with default values to functions with
178
matched against the pattern <I><A HREF="patterns.html#pattern"><FONT COLOR=maroon>pattern</FONT></A></I> and the result is the result of
179
the evaluation of <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> in the extended environment.</P><P>Conversion from functions with default values to functions with
308
180
patterns only works identically for class functions as for normal
313
<FONT COLOR=blue><TT>fun</TT></FONT> <FONT COLOR=maroon><I><TT>parameter</TT></I></FONT><SUB>1</SUB> … <I><FONT COLOR=maroon><TT>parameter</TT></FONT><SUB>n</SUB></I> <FONT COLOR=blue><TT>-></TT></FONT> <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT>
181
functions.</P><P>The expression
182
</P><DIV CLASS="center">
183
<FONT COLOR=blue><TT>fun</TT></FONT> <I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A></I><SUB>1</SUB> … �<I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A><SUB>n</SUB></I> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>
315
185
is a short form for
317
<FONT COLOR=blue><TT>fun</TT></FONT> <FONT COLOR=maroon><I><TT>parameter</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> … <FONT COLOR=blue><TT>fun</TT></FONT> <I><FONT COLOR=maroon><TT>parameter</TT></FONT><SUB>n</SUB></I> <FONT COLOR=blue><TT>-></TT></FONT> <FONT COLOR=maroon><I><TT>expr</TT></I></FONT>
321
<H4 CLASS="subsubsection">Local definitions</H4>
322
The <TT>let</TT> and <TT>let rec</TT> constructs bind value names locally,
323
as for the core language expressions.<BR>
326
<H4 CLASS="subsubsection">Class body</H4>
327
<A NAME="ss:class-body"></A>
186
</P><DIV CLASS="center">
187
<FONT COLOR=blue><TT>fun</TT></FONT> <I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> … <FONT COLOR=blue><TT>fun</TT></FONT> �<I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A><SUB>n</SUB></I> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>
188
</DIV><H4 CLASS="subsubsection">Local definitions</H4><P>The <TT>let</TT> and <TT>let rec</TT> constructs bind value names locally,
189
as for the core language expressions.</P><H4 CLASS="subsubsection">Class<A NAME="ss:class-body"></A> body</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
190
<I><A NAME="class-body"><FONT COLOR=maroon>class-body</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>��[<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="patterns.html#pattern"><FONT COLOR=maroon>pattern</FONT></A></I>��[<FONT COLOR=blue><TT>:</TT></FONT>�<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>]�<FONT COLOR=blue><TT>)</TT></FONT>]��{�<I><A HREF="#class-field"><FONT COLOR=maroon>class-field</FONT></A></I>�}</TD></TR>
329
<FONT COLOR=blue><TT>object</TT> <TT>(</TT></FONT> <FONT COLOR=maroon><I><TT>pattern</TT></I></FONT> [<FONT COLOR=blue><TT>:</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>] <FONT COLOR=blue><TT>)</TT></FONT> { <FONT COLOR=maroon><I><TT>class-field</TT></I></FONT> } <FONT COLOR=blue><TT>end</TT></FONT> denotes
194
<FONT COLOR=blue><TT>object</TT></FONT> <I><A HREF="#class-body"><FONT COLOR=maroon>class-body</FONT></A></I> <FONT COLOR=blue><TT>end</TT></FONT> denotes
330
195
a class body. This is the prototype for an object : it lists the
331
instance variables and methods of an objet of this class.<BR>
333
A class body is a class value: it is not evaluated at once. Rather,
334
its components are evaluated each time an object is created.<BR>
336
In a class body, the pattern <FONT COLOR=blue><TT>(</TT></FONT> <FONT COLOR=maroon><I><TT>pattern</TT></I></FONT> [<FONT COLOR=blue><TT>:</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>] <FONT COLOR=blue><TT>)</TT></FONT> is
196
instance variables and methods of an objet of this class.</P><P>A class body is a class value: it is not evaluated at once. Rather,
197
its components are evaluated each time an object is created.</P><P>In a class body, the pattern <FONT COLOR=blue><TT>(</TT></FONT> <I><A HREF="patterns.html#pattern"><FONT COLOR=maroon>pattern</FONT></A></I> �[<FONT COLOR=blue><TT>:</TT></FONT> <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>] <FONT COLOR=blue><TT>)</TT></FONT> is
337
198
matched against self, therefore provinding a binding for self and self
338
type. Self can only be used in method and initializers.<BR>
340
Self type cannot be a closed object type, so that the class remains
344
<H4 CLASS="subsubsection">Inheritance</H4>
345
<A NAME="@manual.kwd93"></A>
346
The inheritance construct <FONT COLOR=blue><TT>inherit</TT></FONT> <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT> allows to reuse
199
type. Self can only be used in method and initializers.</P><P>Self type cannot be a closed object type, so that the class remains
200
extensible.</P><H4 CLASS="subsubsection">Inheritance</H4><P><A NAME="@manual.kwd94"></A></P><P>The inheritance construct <FONT COLOR=blue><TT>inherit</TT></FONT> <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> allows to reuse
347
201
methods and instance variables from other classes. The class
348
expression <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT> must evaluate to a class body. The instance
202
expression <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I> must evaluate to a class body. The instance
349
203
variables, methods and initializers from this class body are added
350
204
into the current class. The addition of a method will override any
351
previously defined methods of the same name.<BR>
353
<A NAME="@manual.kwd94"></A>
354
An ancestor can be bound by prepending the construct <FONT COLOR=blue><TT>as</TT></FONT> <FONT COLOR=maroon><I><TT>value-name</TT></I></FONT>
355
to the inheritance construct above. <FONT COLOR=maroon><I><TT>value-name</TT></I></FONT> is not a true
205
previously defined methods of the same name.</P><P><A NAME="@manual.kwd95"></A>
206
An ancestor can be bound by prepending the construct <FONT COLOR=blue><TT>as</TT></FONT> <I><A HREF="manual011.html#value-name"><FONT COLOR=maroon>value-name</FONT></A></I>
207
to the inheritance construct above. <I><A HREF="manual011.html#value-name"><FONT COLOR=maroon>value-name</FONT></A></I> is not a true
356
208
variable and can only be used to select a method, i.e. in an expression
357
<FONT COLOR=maroon><TT><I>value-name</I></TT> <FONT COLOR=blue><TT>#</TT></FONT> <TT><I>method-name</I></TT></FONT>. This gives access to the
358
method <FONT COLOR=maroon><I><TT>method-name</TT></I></FONT> as it was defined in the parent class even if it is
209
<I><A HREF="manual011.html#value-name"><FONT COLOR=maroon>value-name</FONT></A></I> <FONT COLOR=blue><TT>#</TT></FONT> �<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>. This gives access to the
210
method <I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I> as it was defined in the parent class even if it is
359
211
redefined in the current class.
360
212
The scope of an ancestor binding is limited to the current class.
361
The ancestor method may be called from a subclass but only indirectly. <BR>
364
<H4 CLASS="subsubsection">Instance variable definition</H4>
365
<A NAME="@manual.kwd95"></A>
366
<A NAME="@manual.kwd96"></A>
367
The definition <FONT COLOR=blue><TT>val</TT></FONT> [<FONT COLOR=blue><TT>mutable</TT></FONT>] <FONT COLOR=maroon><TT><I>inst-var-name</I></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><I>expr</I></TT></FONT> adds an
368
instance variable <FONT COLOR=maroon><I><TT>inst-var-name</TT></I></FONT> whose initial value is the value of
369
expression <FONT COLOR=maroon><I><TT>expr</TT></I></FONT>. Several variables of the same name can be defined
213
The ancestor method may be called from a subclass but only indirectly. </P><H4 CLASS="subsubsection">Instance variable definition</H4><P><A NAME="@manual.kwd96"></A>
214
<A NAME="@manual.kwd97"></A></P><P>The definition <FONT COLOR=blue><TT>val</TT></FONT> [<FONT COLOR=blue><TT>mutable</TT></FONT>] <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I> adds an
215
instance variable <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> whose initial value is the value of
216
expression <I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>.
371
217
The flag <FONT COLOR=blue><TT>mutable</TT></FONT> allows physical modification of this variable by
374
An instance variables can only be used in the following methods and
375
initializers of the class.<BR>
378
<H4 CLASS="subsubsection"><A NAME="xhtoc11"></A>Method definition</H4>
379
<A NAME="@manual.kwd97"></A>
380
<A NAME="@manual.kwd98"></A>
381
Method definition is written <FONT COLOR=blue><TT>method</TT></FONT> <FONT COLOR=maroon><TT><I>method-name</I></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><I>expr</I></TT></FONT>. The
218
methods.</P><P>An instance variables can only be used in the following methods and
219
initializers of the class.</P><P>Since version 3.10, redefinitions of a visible instance variable with
220
the same name do not create a new variable, but are merged, using the
221
last value for initialization. They must have identical types and
223
However, if an instance variable is hidden by
224
omitting it from an interface, it will be kept distinct from
225
other instance variables with the same name.</P><H4 CLASS="subsubsection">Virtual instance variable definition</H4><P><A NAME="@manual.kwd98"></A>
226
<A NAME="@manual.kwd99"></A>
227
<A NAME="@manual.kwd100"></A></P><P>Variable specification is written <FONT COLOR=blue><TT>val</TT></FONT> [<FONT COLOR=blue><TT>mutable</TT></FONT>] <FONT COLOR=blue><TT>virtual</TT></FONT>
228
<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> <FONT COLOR=blue><TT>:</TT></FONT> �<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>. It specifies whether the variable is
229
modifiable, and gives its type.</P><P>Virtual instance variables were added in version 3.10.</P><H4 CLASS="subsubsection">Method definition</H4><P><A NAME="@manual.kwd101"></A>
230
<A NAME="@manual.kwd102"></A></P><P>Method definition is written <FONT COLOR=blue><TT>method</TT></FONT> <I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>. The
382
231
definition of a method overrides any previous definition of this
383
232
method. The method will be public (that is, not private) if any of
384
the definition states so.<BR>
386
A private method, <FONT COLOR=blue><TT>method</TT></FONT> <FONT COLOR=blue><TT>private</TT></FONT> <FONT COLOR=maroon><TT><I>method-name</I></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><I>expr</I></TT></FONT>, is a
233
the definition states so.</P><P>A private method, <FONT COLOR=blue><TT>method</TT> <TT>private</TT></FONT> <I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>, is a
387
234
method that can only be invoked on self (from other methods of the
388
235
same object, defined in this class or one of its subclasses). This
389
236
invocation is performed using the expression
390
<FONT COLOR=maroon><TT><I>value-name</I></TT> <FONT COLOR=blue><TT>#</TT></FONT> <TT><I>method-name</I></TT></FONT>, where <FONT COLOR=maroon><I><TT>value-name</TT></I></FONT> is directly bound to
237
<I><A HREF="manual011.html#value-name"><FONT COLOR=maroon>value-name</FONT></A></I> <FONT COLOR=blue><TT>#</TT></FONT> �<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>, where <I><A HREF="manual011.html#value-name"><FONT COLOR=maroon>value-name</FONT></A></I> is directly bound to
391
238
self at the beginning of the class definition. Private methods do
392
239
not appear in object types. A method may have both public and private
393
240
definitions, but as soon as there is a public one, all subsequent
394
definitions will be made public.<BR>
396
Methods may have an explicitly polymorphic type, allowing them to be
241
definitions will be made public.</P><P>Methods may have an explicitly polymorphic type, allowing them to be
397
242
used polymorphically in programs (even for the same object). The
398
243
explicit declaration may be done in one of three ways: (1) by giving an
399
244
explicit polymorphic type in the method definition, immediately after
400
245
the method name, <EM>i.e.</EM>
401
<FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=maroon><I><TT>method-name</TT></I></FONT> <FONT COLOR=blue><TT>:</TT></FONT> {<FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><TT>ident</TT></I></FONT>}<SUP>+</SUP> <FONT COLOR=blue><TT>.</TT></FONT> <FONT COLOR=maroon><TT><I>typexpr</I></TT> <FONT COLOR=blue><TT>=</TT></FONT>
402
<TT><I>expr</I></TT></FONT>; (2) by a forward declaration of the explicit polymorphic type
246
<FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I> <FONT COLOR=blue><TT>:</TT></FONT> �{<FONT COLOR=blue><TT>'</TT></FONT> <I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>}<SUP>+</SUP> <FONT COLOR=blue><TT>.</TT></FONT> �<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT>
247
�<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>; (2) by a forward declaration of the explicit polymorphic type
403
248
through a virtual method definition; (3) by importing such a
404
declaration through inheritance and/or constraining the type of <EM>self</EM>.<BR>
406
Some special expressions are available in method bodies for
249
declaration through inheritance and/or constraining the type of <EM>self</EM>.</P><P>Some special expressions are available in method bodies for
407
250
manipulating instance variables and duplicating self:
408
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
409
<TR><TD ALIGN=right NOWRAP>
410
<FONT COLOR=maroon><I><a href="manual015.html#expr"><font color=maroon><TT>expr</TT></font></a></I></FONT></TD>
411
<TD ALIGN=right NOWRAP>::=</TD>
412
<TD ALIGN=left NOWRAP>
415
<TR><TD ALIGN=right NOWRAP> </TD>
416
<TD ALIGN=right NOWRAP>∣</TD>
417
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><TT><a href="manual011.html#inst-var-name"><font color=maroon><I>inst-var-name</I></font></a></TT> <FONT COLOR=blue><TT><-</TT></FONT> <TT><a href="manual015.html#expr"><font color=maroon><I>expr</I></font></a></TT></FONT></TD>
419
<TR><TD ALIGN=right NOWRAP> </TD>
420
<TD ALIGN=right NOWRAP>∣</TD>
421
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>{<</TT></FONT> [ <FONT COLOR=maroon><TT><a href="manual011.html#inst-var-name"><font color=maroon><I>inst-var-name</I></font></a></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><a href="manual015.html#expr"><font color=maroon><I>expr</I></font></a></TT></FONT> { <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><TT><a href="manual011.html#inst-var-name"><font color=maroon><I>inst-var-name</I></font></a></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><a href="manual015.html#expr"><font color=maroon><I>expr</I></font></a></TT></FONT> } ] <FONT COLOR=blue><TT>>}</TT></FONT></TD>
422
</TR></TABLE></DIV><BR>
424
The expression <FONT COLOR=maroon><TT><I>inst-var-name</I></TT> <FONT COLOR=blue><TT><-</TT></FONT> <TT><I>expr</I></TT></FONT> modifies in-place the current
425
object by replacing the value associated to <FONT COLOR=maroon><I><TT>inst-var-name</TT></I></FONT> by the
426
value of <FONT COLOR=maroon><I><TT>expr</TT></I></FONT>. Of course, this instance variable must have been
427
declared mutable.<BR>
430
<FONT COLOR=blue><TT>{<</TT></FONT> [ <FONT COLOR=maroon><TT><I>inst-var-name</I></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><I>expr</I></TT></FONT> { <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><TT><I>inst-var-name</I></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><I>expr</I></TT></FONT> } ] <FONT COLOR=blue><TT>>}</TT></FONT>
251
</P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
252
<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
255
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I>�<FONT COLOR=blue><TT><-</TT></FONT>��<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>
257
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>{<</TT></FONT>�[�<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I>�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>��{�<FONT COLOR=blue><TT>;</TT></FONT>�<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I>�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>�}�]�<FONT COLOR=blue><TT>>}</TT></FONT>
259
<TR><TD ALIGN=right NOWRAP> </TD></TR>
261
</TABLE><P>The expression <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> <FONT COLOR=blue><TT><-</TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I> modifies in-place the current
262
object by replacing the value associated to <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> by the
263
value of <I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I>. Of course, this instance variable must have been
264
declared mutable.</P><P>The expression
265
<FONT COLOR=blue><TT>{<</TT></FONT> [ <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I> �{ <FONT COLOR=blue><TT>;</TT></FONT> <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I> } ] <FONT COLOR=blue><TT>>}</TT></FONT>
431
266
evaluates to a copy of the current object in which the values of
432
instance variables <FONT COLOR=maroon><I><TT>inst-var-name</TT></I></FONT><SUB>1</SUB>, …, <I><FONT COLOR=maroon><TT>inst-var-name</TT></FONT><SUB>n</SUB></I> have
433
been replaced by the values of the corresponding expressions <FONT COLOR=maroon><I><TT>expr</TT></I></FONT><SUB>1</SUB>,
434
…, <I><FONT COLOR=maroon><TT>expr</TT></FONT><SUB>n</SUB></I>.<BR>
437
<H4 CLASS="subsubsection">Virtual method definition</H4>
438
<A NAME="@manual.kwd99"></A>
439
<A NAME="@manual.kwd100"></A>
440
<A NAME="@manual.kwd101"></A>
441
Method specification is written <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=blue><TT>virtual</TT></FONT>
442
<FONT COLOR=maroon><TT><I>method-name</I></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><I>poly-typexpr</I></TT></FONT>. It specifies whether the method is
267
instance variables <I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A></I><SUB>1</SUB>, …, �<I><A HREF="manual011.html#inst-var-name"><FONT COLOR=maroon>inst-var-name</FONT></A><SUB>n</SUB></I> have
268
been replaced by the values of the corresponding expressions <I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I><SUB>1</SUB>,
269
…, �<I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A><SUB>n</SUB></I>.</P><H4 CLASS="subsubsection">Virtual method definition</H4><P><A NAME="@manual.kwd103"></A>
270
<A NAME="@manual.kwd104"></A>
271
<A NAME="@manual.kwd105"></A></P><P>Method specification is written <FONT COLOR=blue><TT>method</TT></FONT> [<FONT COLOR=blue><TT>private</TT></FONT>] <FONT COLOR=blue><TT>virtual</TT></FONT>
272
<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I> <FONT COLOR=blue><TT>:</TT></FONT> �<I><A HREF="manual012.html#poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I>. It specifies whether the method is
443
273
public or private, and gives its type. If the method is intended to be
444
polymorphic, the type should be explicit.<BR>
447
<H4 CLASS="subsubsection">Constraints on type parameters</H4>
448
<A NAME="@manual.kwd102"></A>
449
The construct <FONT COLOR=blue><TT>constraint</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>=</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB> forces the two
274
polymorphic, the type should be explicit.</P><H4 CLASS="subsubsection">Constraints on type parameters</H4><P><A NAME="@manual.kwd106"></A></P><P>The construct <FONT COLOR=blue><TT>constraint</TT></FONT> <I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="manual012.html#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB> forces the two
450
275
type expressions to be equals. This is typically used to specify type
451
276
parameters: they can be that way be bound to a specified type
455
<H4 CLASS="subsubsection">Initializers</H4>
456
<A NAME="@manual.kwd103"></A>
457
A class initializer <FONT COLOR=blue><TT>initializer</TT></FONT> <FONT COLOR=maroon><I><TT>expr</TT></I></FONT> specifies an expression that
277
expression.</P><H4 CLASS="subsubsection">Initializers</H4><P><A NAME="@manual.kwd107"></A></P><P>A class initializer <FONT COLOR=blue><TT>initializer</TT></FONT> <I><A HREF="expr.html#expr"><FONT COLOR=maroon>expr</FONT></A></I> specifies an expression that
458
278
will be evaluated when an object will be created from the class, once
459
all the instance variables have been initialized.<BR>
462
<H3 CLASS="subsection"><A NAME="htoc78">6.9.3</A> Class definitions</H3>
463
<A NAME="s:classdef"></A>
464
<A NAME="@manual.kwd104"></A>
465
<A NAME="@manual.kwd105"></A>
466
<A NAME="@manual.kwd106"></A><BR>
468
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
469
<TR><TD ALIGN=right NOWRAP>
470
<A NAME="class-definition"></A>
471
<FONT COLOR=maroon><I><TT>class-definition</TT></I></FONT></TD>
472
<TD ALIGN=right NOWRAP>::=</TD>
473
<TD ALIGN=left NOWRAP>
474
<FONT COLOR=blue><TT>class</TT></FONT> <FONT COLOR=maroon><I><a href="#class-binding"><font color=maroon><TT>class-binding</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>and</TT></FONT> <FONT COLOR=maroon><I><a href="#class-binding"><font color=maroon><TT>class-binding</TT></font></a></I></FONT> }</TD>
476
<TR><TD ALIGN=right NOWRAP>
477
<A NAME="class-binding"></A>
478
<FONT COLOR=maroon><I><TT>class-binding</TT></I></FONT></TD>
479
<TD ALIGN=right NOWRAP>::=</TD>
480
<TD ALIGN=left NOWRAP>
481
[<FONT COLOR=blue><TT>virtual</TT></FONT>] [<FONT COLOR=blue><TT>[</TT> <FONT COLOR=maroon><TT><a href="#type-parameters"><font color=maroon><I>type-parameters</I></font></a></TT></FONT> <TT>]</TT></FONT>] <FONT COLOR=maroon><I><a href="manual011.html#class-name"><font color=maroon><TT>class-name</TT></font></a></I></FONT>
482
{<FONT COLOR=maroon><I><a href="manual015.html#parameter"><font color=maroon><TT>parameter</TT></font></a></I></FONT>} [<FONT COLOR=blue><TT>:</TT></FONT> <FONT COLOR=maroon><I><a href="#class-type"><font color=maroon><TT>class-type</TT></font></a></I></FONT>] <FONT COLOR=blue><TT>=</TT></FONT> <FONT COLOR=maroon><I><a href="#class-expr"><font color=maroon><TT>class-expr</TT></font></a></I></FONT></TD>
484
<TR><TD ALIGN=right NOWRAP>
485
<A NAME="type-parameters"></A>
486
<FONT COLOR=maroon><I><TT>type-parameters</TT></I></FONT></TD>
487
<TD ALIGN=right NOWRAP>::=</TD>
488
<TD ALIGN=left NOWRAP>
489
<FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><a href="manual009.html#ident"><font color=maroon><TT>ident</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>,</TT> <TT>'</TT></FONT> <FONT COLOR=maroon><I><a href="manual009.html#ident"><font color=maroon><TT>ident</TT></font></a></I></FONT> }</TD>
490
</TR></TABLE></DIV><BR>
492
A class definition <FONT COLOR=blue><TT>class</TT></FONT> <FONT COLOR=maroon><I><TT>class-binding</TT></I></FONT> { <FONT COLOR=blue><TT>and</TT></FONT> <FONT COLOR=maroon><I><TT>class-binding</TT></I></FONT> } is
493
recursive. Each <FONT COLOR=maroon><I><TT>class-binding</TT></I></FONT> defines a <FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> that can be
279
all the instance variables have been initialized.</P><H3 CLASS="subsection"><A NAME="htoc78">6.9.3</A>��Class definitions</H3><P>
280
<A NAME="s:classdef"></A></P><P><A NAME="@manual.kwd108"></A>
281
<A NAME="@manual.kwd109"></A>
282
<A NAME="@manual.kwd110"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
283
<I><A NAME="class-definition"><FONT COLOR=maroon>class-definition</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
284
<FONT COLOR=blue><TT>class</TT></FONT>�<I><A HREF="#class-binding"><FONT COLOR=maroon>class-binding</FONT></A></I>��{�<FONT COLOR=blue><TT>and</TT></FONT>�<I><A HREF="#class-binding"><FONT COLOR=maroon>class-binding</FONT></A></I>�}
286
<TR><TD ALIGN=right NOWRAP> </TD></TR>
287
<TR><TD ALIGN=right NOWRAP>
288
<I><A NAME="class-binding"><FONT COLOR=maroon>class-binding</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
289
[<FONT COLOR=blue><TT>virtual</TT></FONT>]�[<FONT COLOR=blue><TT>[</TT></FONT>�<I><A HREF="#type-parameters"><FONT COLOR=maroon>type-parameters</FONT></A></I>�<FONT COLOR=blue><TT>]</TT></FONT>]��<I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I>
290
�{<I><A HREF="expr.html#parameter"><FONT COLOR=maroon>parameter</FONT></A></I>}��[<FONT COLOR=blue><TT>:</TT></FONT>�<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>]��<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>
292
<TR><TD ALIGN=right NOWRAP> </TD></TR>
293
<TR><TD ALIGN=right NOWRAP>
294
<I><A NAME="type-parameters"><FONT COLOR=maroon>type-parameters</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
295
<FONT COLOR=blue><TT>'</TT></FONT>�<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>��{�<FONT COLOR=blue><TT>,</TT></FONT>�<FONT COLOR=blue><TT>'</TT></FONT>�<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>�}
297
<TR><TD ALIGN=right NOWRAP> </TD></TR>
299
</TABLE><P>A class definition <FONT COLOR=blue><TT>class</TT></FONT> <I><A HREF="#class-binding"><FONT COLOR=maroon>class-binding</FONT></A></I> �{ <FONT COLOR=blue><TT>and</TT></FONT> <I><A HREF="#class-binding"><FONT COLOR=maroon>class-binding</FONT></A></I> } is
300
recursive. Each <I><A HREF="#class-binding"><FONT COLOR=maroon>class-binding</FONT></A></I> defines a <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> that can be
494
301
used in the whole expression except for inheritance. It can also be
495
used for inheritance, but only in the definitions that follow its own.<BR>
497
A class binding binds the class name <FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> to the value of
498
expression <FONT COLOR=maroon><I><TT>class-expr</TT></I></FONT>. It also binds the class type <FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> to
302
used for inheritance, but only in the definitions that follow its own.</P><P>A class binding binds the class name <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> to the value of
303
expression <I><A HREF="#class-expr"><FONT COLOR=maroon>class-expr</FONT></A></I>. It also binds the class type <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> to
499
304
the type of the class, and defines two type abbreviations :
500
<FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> and <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><I><TT>class-name</TT></I></FONT>. The first one is the type of
305
<I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> and <FONT COLOR=blue><TT>#</TT></FONT> <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I>. The first one is the type of
501
306
objects of this class, while the second is more general as it unifies
502
307
with the type of any object belonging to a subclass (see
503
section <A HREF="manual012.html#s:sharp-types">6.4</A>).<BR>
506
<H4 CLASS="subsubsection">Virtual class</H4>
507
<A NAME="@manual.kwd107"></A>
308
section�<A HREF="manual012.html#s:sharp-types">6.4</A>).</P><H4 CLASS="subsubsection">Virtual class</H4><P><A NAME="@manual.kwd111"></A>
508
309
A class must be flagged virtual if one of its methods is virtual (that
509
310
is, appears in the class type, but is not actually defined).
510
Objects cannot be created from a virtual class.<BR>
513
<H4 CLASS="subsubsection">Type parameters</H4>
514
The class type parameters correspond to the ones of the class type and
311
Objects cannot be created from a virtual class.</P><H4 CLASS="subsubsection">Type parameters</H4><P>The class type parameters correspond to the ones of the class type and
515
312
of the two type abbreviations defined by the class binding. They must
516
313
be bound to actual types in the class definition using type
517
314
constraints. So that the abbreviations are well-formed, type
518
315
variables of the inferred type of the class must either be type
519
parameters or be bound in the constraint clause.<BR>
522
<H3 CLASS="subsection"><A NAME="htoc79">6.9.4</A> Class specification</H3>
523
<A NAME="s:class-spec"></A>
524
<A NAME="@manual.kwd108"></A>
525
<A NAME="@manual.kwd109"></A>
526
<A NAME="@manual.kwd110"></A><BR>
528
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
529
<TR><TD ALIGN=right NOWRAP>
530
<A NAME="class-specification"></A>
531
<FONT COLOR=maroon><I><TT>class-specification</TT></I></FONT></TD>
532
<TD ALIGN=right NOWRAP>::=</TD>
533
<TD ALIGN=left NOWRAP>
534
<FONT COLOR=blue><TT>class</TT></FONT> <FONT COLOR=maroon><I><a href="#class-spec"><font color=maroon><TT>class-spec</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>and</TT></FONT> <FONT COLOR=maroon><I><a href="#class-spec"><font color=maroon><TT>class-spec</TT></font></a></I></FONT> }</TD>
536
<TR><TD ALIGN=right NOWRAP>
537
<A NAME="class-spec"></A>
538
<FONT COLOR=maroon><I><TT>class-spec</TT></I></FONT></TD>
539
<TD ALIGN=right NOWRAP>::=</TD>
540
<TD ALIGN=left NOWRAP>
541
[<FONT COLOR=blue><TT>virtual</TT></FONT>] [<FONT COLOR=blue><TT>[</TT> <FONT COLOR=maroon><TT><a href="#type-parameters"><font color=maroon><I>type-parameters</I></font></a></TT></FONT> <TT>]</TT></FONT>] <FONT COLOR=maroon><TT><a href="manual011.html#class-name"><font color=maroon><I>class-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="#class-type"><font color=maroon><I>class-type</I></font></a></TT></FONT></TD>
542
</TR></TABLE></DIV><BR>
544
This is the counterpart in signatures of class definitions.
316
parameters or be bound in the constraint clause.</P><H3 CLASS="subsection"><A NAME="htoc79">6.9.4</A>��Class specification</H3><P>
317
<A NAME="s:class-spec"></A></P><P><A NAME="@manual.kwd112"></A>
318
<A NAME="@manual.kwd113"></A>
319
<A NAME="@manual.kwd114"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
320
<I><A NAME="class-specification"><FONT COLOR=maroon>class-specification</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
321
<FONT COLOR=blue><TT>class</TT></FONT>�<I><A HREF="#class-spec"><FONT COLOR=maroon>class-spec</FONT></A></I>��{�<FONT COLOR=blue><TT>and</TT></FONT>�<I><A HREF="#class-spec"><FONT COLOR=maroon>class-spec</FONT></A></I>�}
323
<TR><TD ALIGN=right NOWRAP> </TD></TR>
324
<TR><TD ALIGN=right NOWRAP>
325
<I><A NAME="class-spec"><FONT COLOR=maroon>class-spec</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
326
[<FONT COLOR=blue><TT>virtual</TT></FONT>]�[<FONT COLOR=blue><TT>[</TT></FONT>�<I><A HREF="#type-parameters"><FONT COLOR=maroon>type-parameters</FONT></A></I>�<FONT COLOR=blue><TT>]</TT></FONT>]��<I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>
327
�<I><A HREF="#class-type"><FONT COLOR=maroon>class-type</FONT></A></I>
329
<TR><TD ALIGN=right NOWRAP> </TD></TR>
331
</TABLE><P>This is the counterpart in signatures of class definitions.
545
332
A class specification matches a class definition if they have the same
546
type parameters and their types match.<BR>
549
<H3 CLASS="subsection"><A NAME="htoc80">6.9.5</A> Class type definitions</H3>
550
<A NAME="s:classtype"></A>
551
<A NAME="@manual.kwd111"></A>
552
<A NAME="@manual.kwd112"></A>
553
<A NAME="@manual.kwd113"></A>
554
<A NAME="@manual.kwd114"></A><BR>
556
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
557
<TR><TD ALIGN=right NOWRAP>
558
<A NAME="classtype-definition"></A>
559
<FONT COLOR=maroon><I><TT>classtype-definition</TT></I></FONT></TD>
560
<TD ALIGN=right NOWRAP>::=</TD>
561
<TD ALIGN=left NOWRAP>
562
<FONT COLOR=blue><TT>class</TT> <TT>type</TT></FONT> <FONT COLOR=maroon><I><a href="#classtype-def"><font color=maroon><TT>classtype-def</TT></font></a></I></FONT>
563
{ <FONT COLOR=blue><TT>and</TT></FONT> <FONT COLOR=maroon><I><a href="#classtype-def"><font color=maroon><TT>classtype-def</TT></font></a></I></FONT> }</TD>
565
<TR><TD ALIGN=right NOWRAP>
566
<A NAME="classtype-def"></A>
567
<FONT COLOR=maroon><I><TT>classtype-def</TT></I></FONT></TD>
568
<TD ALIGN=right NOWRAP>::=</TD>
569
<TD ALIGN=left NOWRAP>
570
[<FONT COLOR=blue><TT>virtual</TT></FONT>] [<FONT COLOR=blue><TT>[</TT> <FONT COLOR=maroon><TT><a href="#type-parameters"><font color=maroon><I>type-parameters</I></font></a></TT></FONT> <TT>]</TT></FONT>] <FONT COLOR=maroon><TT><a href="manual011.html#class-name"><font color=maroon><I>class-name</I></font></a></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><a href="#class-body-type"><font color=maroon><I>class-body-type</I></font></a></TT></FONT></TD>
571
</TR></TABLE></DIV><BR>
573
A class type definition <FONT COLOR=blue><TT>class</TT></FONT> <FONT COLOR=maroon><TT><I>class-name</I></TT> <FONT COLOR=blue><TT>=</TT></FONT> <TT><I>class-body-type</I></TT></FONT>
574
defines an abbreviation <FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> for the class body type
575
<FONT COLOR=maroon><I><TT>class-body-type</TT></I></FONT>. As for class definitions, two type abbreviations
576
<FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> and <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><I><TT>class-name</TT></I></FONT> are also defined. The definition can
333
type parameters and their types match.</P><H3 CLASS="subsection"><A NAME="htoc80">6.9.5</A>��Class type definitions</H3><P>
334
<A NAME="s:classtype"></A></P><P><A NAME="@manual.kwd115"></A>
335
<A NAME="@manual.kwd116"></A>
336
<A NAME="@manual.kwd117"></A>
337
<A NAME="@manual.kwd118"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
338
<I><A NAME="classtype-definition"><FONT COLOR=maroon>classtype-definition</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
339
<FONT COLOR=blue><TT>class</TT></FONT>�<FONT COLOR=blue><TT>type</TT></FONT>�<I><A HREF="#classtype-def"><FONT COLOR=maroon>classtype-def</FONT></A></I>
340
�{�<FONT COLOR=blue><TT>and</TT></FONT>�<I><A HREF="#classtype-def"><FONT COLOR=maroon>classtype-def</FONT></A></I>�}
342
<TR><TD ALIGN=right NOWRAP> </TD></TR>
343
<TR><TD ALIGN=right NOWRAP>
344
<I><A NAME="classtype-def"><FONT COLOR=maroon>classtype-def</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
345
[<FONT COLOR=blue><TT>virtual</TT></FONT>]�[<FONT COLOR=blue><TT>[</TT></FONT>�<I><A HREF="#type-parameters"><FONT COLOR=maroon>type-parameters</FONT></A></I>�<FONT COLOR=blue><TT>]</TT></FONT>]��<I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I>�<FONT COLOR=blue><TT>=</TT></FONT>��<I><A HREF="#class-body-type"><FONT COLOR=maroon>class-body-type</FONT></A></I>
347
<TR><TD ALIGN=right NOWRAP> </TD></TR>
349
</TABLE><P>A class type definition <FONT COLOR=blue><TT>class</TT></FONT> <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> <FONT COLOR=blue><TT>=</TT></FONT> �<I><A HREF="#class-body-type"><FONT COLOR=maroon>class-body-type</FONT></A></I>
350
defines an abbreviation <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> for the class body type
351
<I><A HREF="#class-body-type"><FONT COLOR=maroon>class-body-type</FONT></A></I>. As for class definitions, two type abbreviations
352
<I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> and <FONT COLOR=blue><TT>#</TT></FONT> <I><A HREF="manual011.html#class-name"><FONT COLOR=maroon>class-name</FONT></A></I> are also defined. The definition can
577
353
be parameterized by some type parameters. If any method in the class
578
type body is virtual, the definition must be flagged <FONT COLOR=maroon><I><TT>virtual</TT></I></FONT>.<BR>
580
Two class type definitions match if they have the same type parameters
354
type body is virtual, the definition must be flagged <FONT COLOR=blue><TT>virtual</TT></FONT>.</P><P>Two class type definitions match if they have the same type parameters
581
355
and the types they expand to match.
586
<A HREF="manual016.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
587
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
588
<A HREF="manual018.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
358
<A HREF="manual016.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
359
<A HREF="manual008.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
360
<A HREF="manual018.html"><IMG SRC="next_motif.gif" ALT="Next"></A>