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 s
path: root/tangle.mu
blob: 4b13c910d3abf12dc4693ae1b6fcdbf701eef214 (plain) (tree)
1
2
3
4
5
6
7
8
9