-
Notifications
You must be signed in to change notification settings - Fork 22
Description
This is a followup of:
There are two conflicting designs at play here:
-
Nim's distinction between
T(x)andcast[T](x)implies that runtime checks forT(x)are always anticipated and desired. This is what the spec for version 1 says and no special casing forunsignedis mentioned. -
Unsigned numbers are heavily used in low level contexts and diverging too much from C's behaviour is confusing and dangerous. Arithmetic operations on unsigned wrap around because of this requirement.
In the past Nim followed (2) but starting with version 1 Nim followed its own spec. This RFC proposes to change the spec to reflect what was true in previous Nim versions.
Note that either (1) or (2) is fine from a design standpoint IMO but the legacy code relies on (2) (including Nim's own library) and now the compiler inserts time ticking bombs in the form of secret runtime checks that can result in exceptions being raised without any warnings. This is bad enough to revert it to the old behavior and change the spec so that it matches Nim's historical behavior.