From c98e0e22ad7bf7772eb0ef3f50b7f67f33ec8905 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 20 Nov 2019 17:08:43 +0100 Subject: conversions to unsigned numbers are not checked anymore; implements /… (#12688) [backport] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * conversions to unsigned numbers are not checked anymore; implements / fixes https://github.com/nim-lang/RFCs/issues/175 * change the spec yet again to be less consistent but to make more sense; updated the changelog --- doc/manual.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc') diff --git a/doc/manual.rst b/doc/manual.rst index c869b391f..82487a385 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -3188,6 +3188,7 @@ has lots of advantages: Type conversions ---------------- + Syntactically a `type conversion` is like a procedure call, but a type name replaces the procedure name. A type conversion is always safe in the sense that a failure to convert a type to another @@ -3207,6 +3208,19 @@ A type conversion can also be used to disambiguate overloaded routines: let procVar = (proc(x: string))(p) procVar("a") +Since operations on unsigned numbers wrap around and are unchecked so are +type conversion to unsigned integers and between unsigned integers. The +rationale for this is mostly better interoperability with the C Programming +language when algorithms are ported from C to Nim. + +Exception: Values that are converted to an unsigned type at compile time +are checked so that code like ``byte(-1)`` does not compile. + +**Note**: Historically the operations +were unchecked and the conversions were sometimes checked but starting with +the revision 1.0.4 of this document and the language implementation the +conversions too are now *always unchecked*. + Type casts ---------- -- cgit 1.4.1-2-gfad0 'right' method='get' action='/ahoang/Nim/log/lib/pure/segfaults.nim'>
path: root/lib/pure/segfaults.nim
blob: 27572b6ffa7cb3b5f166fa85632e742f91e3c1d1 (plain) (blame)
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