File: manual009.html

package info (click to toggle)
ocaml-doc 2.04-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,820 kB
  • ctags: 997
  • sloc: makefile: 38; sh: 12
file content (298 lines) | stat: -rw-r--r-- 13,077 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!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">
<TITLE>
 Names
</TITLE>
</HEAD>
<BODY >
<A HREF="manual008.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual010.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual006.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>

<H2>5.3&nbsp;&nbsp; Names</H2> <A NAME="s:names"></A>
Identifiers are used to give names to several classes of language
objects and refer to these objects by name later:
<UL>
<LI>
value names (syntactic class <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT>),

<LI>value constructors (constant -- class <TT><I><FONT COLOR=maroon>cconstr-name</FONT></I></TT> -- or
non-constant -- class <TT><I><FONT COLOR=maroon>ncconstr-name</FONT></I></TT>),

<LI>type constructors (<TT><I><FONT COLOR=maroon>typeconstr-name</FONT></I></TT>),

<LI>record labels (<TT><I><FONT COLOR=maroon>label-name</FONT></I></TT>),

<LI>class names (<TT><I><FONT COLOR=maroon>class-name</FONT></I></TT>),

<LI>method names (<TT><I><FONT COLOR=maroon>method-name</FONT></I></TT>),

<LI>instance variable names (<TT><I><FONT COLOR=maroon>inst-var-name</FONT></I></TT>),

<LI>module names (<TT><I><FONT COLOR=maroon>module-name</FONT></I></TT>),

<LI>module type names (<TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT>).
</UL>
These nine name spaces are distinguished both by the context and by the
capitalization of the identifier: whether the first letter of the
identifier is in lowercase (written <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT> below) or in
uppercase (written <TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT>). Underscore is considered a
lowercase letter for this purpose.<A NAME="@manual.kwd0"></A><BR>
<BR>

<A NAME="@manual.kwd1"></A><BR>
<BR>

<H4>Naming objects</H4><DIV ALIGN=center>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>value-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>operator-name</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>operator-name</FONT></I></TT></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>infix-symbol</FONT></I></TT> |  <TT><FONT COLOR=blue>*</FONT></TT> |  <TT><FONT COLOR=blue>=</FONT></TT> |  <TT><FONT COLOR=blue>or</FONT></TT> |  <TT><FONT COLOR=blue>&amp;</FONT></TT> |  <TT><FONT COLOR=blue>:=</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>cconstr-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><FONT COLOR=blue>false</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><FONT COLOR=blue>true</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><FONT COLOR=blue>[</FONT></TT> <TT><FONT COLOR=blue>]</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>ncconstr-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><FONT COLOR=blue>::</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>typeconstr-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>label-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>module-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>class-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>inst-var-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>method-name</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR></TABLE></DIV>
As shown above, prefix and infix symbols as well as some keywords can
be used as value names, provided they are written between parentheses.
Keywords such as '::' and 'false' are also constructor names. The
capitalization rules are summarized in the table
below.<BR>
<BR>
<BR>
<BR>
<DIV ALIGN=center>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
<TR><TD  ALIGN=center NOWRAP><B>Name space</B></TD>
<TD  ALIGN=center NOWRAP><B>Case of first letter</B></TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>
Values</TD>
<TD  ALIGN=left NOWRAP>lowercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Constructors</TD>
<TD  ALIGN=left NOWRAP>uppercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Type constructors</TD>
<TD  ALIGN=left NOWRAP>lowercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Record labels</TD>
<TD  ALIGN=left NOWRAP>lowercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Classes</TD>
<TD  ALIGN=left NOWRAP>lowercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Methods</TD>
<TD  ALIGN=left NOWRAP>lowercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Modules</TD>
<TD  ALIGN=left NOWRAP>uppercase</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>Module types</TD>
<TD  ALIGN=left NOWRAP>any</TD>
</TR></TABLE></DIV><BR>

<H4>Referring to named objects</H4><DIV ALIGN=center>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>value-path</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>cconstr</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>cconstr-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>ncconstr</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>ncconstr-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>typeconstr-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>label</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>label-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>module-path</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>capitalized-ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> <TT><FONT COLOR=blue>(</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>modtype-path</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>ident</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>class-path</FONT></I></TT></TD>
<TD  ALIGN=right NOWRAP>::=</TD>
<TD  ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>class-name</FONT></I></TT></TD>
</TR>
<TR><TD  ALIGN=right NOWRAP>&nbsp;</TD>
<TD  ALIGN=right NOWRAP>|</TD>
<TD  ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>lowercase-ident</FONT></I></TT></TD>
</TR></TABLE></DIV><BR>
A named object can be referred to either by its name (following the
usual static scoping rules for names) or by an access path <TT><I><FONT COLOR=maroon>prefix</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT>,
where <TT><I><FONT COLOR=maroon>prefix</FONT></I></TT> designates a module and <TT><I><FONT COLOR=maroon>name</FONT></I></TT> is the name of an object
defined in that module. The first component of the path, <TT><I><FONT COLOR=maroon>prefix</FONT></I></TT>, is
either a simple module name or an access path <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> ...,
in case the defining module is itself nested inside other modules.
For referring to type constructors or module types, the <TT><I><FONT COLOR=maroon>prefix</FONT></I></TT> can
also contain simple functor applications (as in the syntactic class
<TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> above), in case the defining module is the
result of a functor application.<BR>
<BR>
Instance variable names and method names need not be qualified: the
former are local to a class while the latter are global labels.

<BR>
<BR>
<HR>
<A HREF="manual008.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual010.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual006.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>