diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-11-20 17:08:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 17:08:43 +0100 |
commit | c98e0e22ad7bf7772eb0ef3f50b7f67f33ec8905 (patch) | |
tree | 6ec8ee4149105307bfabb42444e979be890e7edc /doc | |
parent | 85ffcd80c05ae1bbf853121059c39a215a29ae54 (diff) | |
download | Nim-c98e0e22ad7bf7772eb0ef3f50b7f67f33ec8905.tar.gz |
conversions to unsigned numbers are not checked anymore; implements /… (#12688) [backport]
* 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
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.rst | 14 |
1 files changed, 14 insertions, 0 deletions
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 ---------- |