summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorStefan Talpalaru <stefantalpalaru@yahoo.com>2015-06-15 08:44:02 +0200
committerStefan Talpalaru <stefantalpalaru@yahoo.com>2015-06-15 08:44:02 +0200
commitbdac85f2cfbff9bab11f06c72f364523936a5487 (patch)
tree41313479b483459e312280cf42b6f862acba4bd3 /doc
parent657d6f9de2d8fc8960fb703f927db2ff2070d5a4 (diff)
parent8c671d22d6a7c55e13e7c02eb4fd65bbabb52131 (diff)
downloadNim-bdac85f2cfbff9bab11f06c72f364523936a5487.tar.gz
Merge branch 'devel' into gogc
Diffstat (limited to 'doc')
-rw-r--r--doc/exception_hierarchy_fragment.txt4
-rw-r--r--doc/manual/generics.txt6
-rw-r--r--doc/manual/lexing.txt50
-rw-r--r--doc/manual/modules.txt8
-rw-r--r--doc/manual/procs.txt2
5 files changed, 47 insertions, 23 deletions
diff --git a/doc/exception_hierarchy_fragment.txt b/doc/exception_hierarchy_fragment.txt
index f4a419fc4..a02d9ccef 100644
--- a/doc/exception_hierarchy_fragment.txt
+++ b/doc/exception_hierarchy_fragment.txt
@@ -11,8 +11,8 @@
     * `FloatInvalidOpError <system.html#FloatInvalidOpError>`_
     * `FloatOverflowError <system.html#FloatOverflowError>`_
     * `FloatUnderflowError <system.html#FloatUnderflowError>`_
-  * `FieldError <system.html#InvalidFieldError>`_
-  * `IndexError <system.html#InvalidIndexError>`_
+  * `FieldError <system.html#FieldError>`_
+  * `IndexError <system.html#IndexError>`_
   * `ObjectAssignmentError <system.html#ObjectAssignmentError>`_
   * `ObjectConversionError <system.html#ObjectConversionError>`_
   * `ValueError <system.html#ValueError>`_
diff --git a/doc/manual/generics.txt b/doc/manual/generics.txt
index 2736f88fb..f82cad531 100644
--- a/doc/manual/generics.txt
+++ b/doc/manual/generics.txt
@@ -164,11 +164,13 @@ Alternatively, the ``distinct`` type modifier can be applied to the type class
 to allow each param matching the type class to bind to a different type.
 
 If a proc param doesn't have a type specified, Nim will use the
-``distinct auto`` type class (also known as ``any``):
+``distinct auto`` type class (also known as ``any``). Note this behavior is 
+deprecated for procs; templates, however, support them:
 
 .. code-block:: nim
   # allow any combination of param types
-  proc concat(a, b): string = $a & $b
+  proc concat(a, b): string = $a & $b # deprecated
+  proc concat(a, b: any): string = $a & $b # preferred
 
 Procs written with the implicitly generic style will often need to refer to the
 type parameters of the matched generic type. They can be easily accessed using
diff --git a/doc/manual/lexing.txt b/doc/manual/lexing.txt
index ab1cd632d..9419f8453 100644
--- a/doc/manual/lexing.txt
+++ b/doc/manual/lexing.txt
@@ -101,25 +101,28 @@ Two identifiers are considered equal if the following algorithm returns true:
 
 .. code-block:: nim
   proc sameIdentifier(a, b: string): bool =
-    a[0] == b[0] and a.replace("_", "").toLower == b.replace("_", "").toLower
+    a[0] == b[0] and
+      a.replace(re"_|–", "").toLower == b.replace(re"_|–", "").toLower
 
 That means only the first letters are compared in a case sensitive manner. Other
-letters are compared case insensitively and underscores are ignored.
+letters are compared case insensitively and underscores and en-dash (Unicode
+point U+2013) are ignored.
 
-This rather strange way to do identifier comparisons is called
+This rather unorthodox way to do identifier comparisons is called
 `partial case insensitivity`:idx: and has some advantages over the conventional
 case sensitivity:
 
 It allows programmers to mostly use their own preferred
-spelling style and libraries written by different programmers cannot use
-incompatible conventions. A Nim-aware editor or IDE can show the identifiers as
-preferred. Another advantage is that it frees the programmer from remembering
+spelling style, be it humpStyle, snake_style or dash–style and libraries written
+by different programmers cannot use incompatible conventions.
+A Nim-aware editor or IDE can show the identifiers as preferred.
+Another advantage is that it frees the programmer from remembering
 the exact spelling of an identifier. The exception with respect to the first
 letter allows common code like ``var foo: Foo`` to be parsed unambiguously.
 
-Historically, Nim was a `style-insensitive`:idx: language. This means that it
-was not case-sensitive and underscores were ignored and there was no distinction
-between ``foo`` and ``Foo``.
+Historically, Nim was a fully `style-insensitive`:idx: language. This meant that
+it was not case-sensitive and underscores were ignored and there was no even a
+distinction between ``foo`` and ``Foo``.
 
 
 String literals
@@ -276,7 +279,7 @@ Numerical constants are of a single type and have the form::
   bindigit = '0'..'1'
   HEX_LIT = '0' ('x' | 'X' ) hexdigit ( ['_'] hexdigit )*
   DEC_LIT = digit ( ['_'] digit )*
-  OCT_LIT = '0o' octdigit ( ['_'] octdigit )*
+  OCT_LIT = '0' ('o' | 'c' | 'C') octdigit ( ['_'] octdigit )*
   BIN_LIT = '0' ('b' | 'B' ) bindigit ( ['_'] bindigit )*
   
   INT_LIT = HEX_LIT
@@ -297,15 +300,17 @@ Numerical constants are of a single type and have the form::
 
   exponent = ('e' | 'E' ) ['+' | '-'] digit ( ['_'] digit )*
   FLOAT_LIT = digit (['_'] digit)* (('.' (['_'] digit)* [exponent]) |exponent)
-  FLOAT32_LIT = HEX_LIT '\'' ('f'|'F') '32'
-              | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] ('f'|'F') '32'
-  FLOAT64_LIT = HEX_LIT '\'' ('f'|'F') '64'
-              | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] ('f'|'F') '64'
+  FLOAT32_SUFFIX = ('f' | 'F') ['32']
+  FLOAT32_LIT = HEX_LIT '\'' FLOAT32_SUFFIX
+              | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] FLOAT32_SUFFIX
+  FLOAT64_SUFFIX = ( ('f' | 'F') '64' ) | 'd' | 'D'
+  FLOAT64_LIT = HEX_LIT '\'' FLOAT64_SUFFIX
+              | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] FLOAT64_SUFFIX
 
 
 As can be seen in the productions, numerical constants can contain underscores
 for readability. Integer and floating point literals may be given in decimal (no
-prefix), binary (prefix ``0b``), octal (prefix ``0o``) and hexadecimal
+prefix), binary (prefix ``0b``), octal (prefix ``0o`` or ``0c``) and hexadecimal
 (prefix ``0x``) notation.
 
 There exists a literal for each numerical type that is
@@ -331,8 +336,11 @@ The type suffixes are:
   ``'u16``           uint16
   ``'u32``           uint32
   ``'u64``           uint64
+  ``'f``             float32
+  ``'d``             float64
   ``'f32``           float32
   ``'f64``           float64
+  ``'f128``          float128
 =================    =========================
 
 Floating point literals may also be in binary, octal or hexadecimal
@@ -340,12 +348,18 @@ notation:
 ``0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64``
 is approximately 1.72826e35 according to the IEEE floating point standard.
 
+Literals are bounds checked so that they fit the datatype. Non base-10
+literals are used mainly for flags and bit pattern representations, therefore
+bounds checking is done on bit width, not value range. If the literal fits in
+the bit width of the datatype, it is accepted.
+Hence: 0b10000000'u8 == 0x80'u8 == 128, but, 0b10000000'i8 == 0x80'i8 == -1
+instead of causing an overflow error.
 
 Operators
 ---------
 
-In Nim one can define his own operators. An operator is any
-combination of the following characters::
+Nim allows user defined operators. An operator is any combination of the
+following characters::
 
        =     +     -     *     /     <     >
        @     $     ~     &     %     |
@@ -355,7 +369,7 @@ These keywords are also operators:
 ``and or not xor shl shr div mod in notin is isnot of``.
 
 `=`:tok:, `:`:tok:, `::`:tok: are not available as general operators; they
-are used for other notational purposes. 
+are used for other notational purposes.
 
 ``*:`` is as a special case the two tokens `*`:tok: and `:`:tok:
 (to support ``var v*: T``).
diff --git a/doc/manual/modules.txt b/doc/manual/modules.txt
index fe3360773..813505769 100644
--- a/doc/manual/modules.txt
+++ b/doc/manual/modules.txt
@@ -146,6 +146,14 @@ modules don't need to import a module's dependencies:
   var x: MyObject
   echo($x)
 
+Note on paths
+-----------
+In module related statements, if any part of the module name /
+path begins with a number, you may have to quote it in double quotes.
+In the following example, it would be seen as a literal number '3.0' of type
+'float64' if not quoted, if uncertain - quote it:
+.. code-block:: nim
+  import "gfx/3d/somemodule"
 
 Scope rules
 -----------
diff --git a/doc/manual/procs.txt b/doc/manual/procs.txt
index 38e343686..23b5e4d1e 100644
--- a/doc/manual/procs.txt
+++ b/doc/manual/procs.txt
@@ -404,7 +404,7 @@ dispatch.
     result.a = a
     result.b = b
 
-echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4)))
+  echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4)))
   
 In the example the constructors ``newLit`` and ``newPlus`` are procs
 because they should use static binding, but ``eval`` is a method because it
> ^
e25474154 ^



e25474154 ^
a58a2f382 ^

e25474154 ^

e25474154 ^
e25474154 ^
a58a2f382 ^
064417fc5 ^
a58a2f382 ^


e25474154 ^
48dd9679b ^
a58a2f382 ^
e25474154 ^
8ce705f68 ^
e25474154 ^
8ce705f68 ^
e25474154 ^







f8dd74a07 ^
e25474154 ^


e25474154 ^

064417fc5 ^

e25474154 ^
064417fc5 ^
a58a2f382 ^
e25474154 ^










064417fc5 ^
e25474154 ^







0b197ade6 ^



e25474154 ^


064417fc5 ^
a58a2f382 ^
e25474154 ^


3e9dcc8be ^
e25474154 ^








e25474154 ^


8ce705f68 ^
e25474154 ^






8ce705f68 ^
e25474154 ^


8ce705f68 ^
e25474154 ^








a58a2f382 ^
e25474154 ^





8ce705f68 ^
e25474154 ^

8ce705f68 ^
e25474154 ^
8ce705f68 ^
e25474154 ^

8ce705f68 ^

e25474154 ^
















f530bbd63 ^
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409