Swapped syntax for Natural numbers and Integers
Migrate your code to support the change in syntax for
Natural
numbers andInteger
s
On May 7, 2018 the language standard changed to swap the syntax for Natural
numbers and Integer
s. This section describes what changed and how to migrate your code.
Changes
Before the change, the standard specified that:
literal numbers with a leading
+
wereNatural
numbers,literal numbers without a leading sign were
Integer
s, and:literal numbers with a leading
-
wereInteger
s.
In other words:
-- Before
+2 : Natural
2 : Integer
-2 : Integer
After the change, the standard specifies that:
literal numbers without a leading sign are
Natural
numbers, and:literal numbers with a leading sign (both
+
and-
) areInteger
s.
In other words:
-- After
2 : Natural
+2 : Integer
-2 : Integer
Additionally, Natural/show
was changed to render Natural
numbers without the leading sign and Integer/show
was changed to render non-negative Integer
s with a leading +
sign:
-- Before
Natural/show +2 = "+2"
Integer/show 2 = "2"
Integer/show -2 = "-2"
-- After
Natural/show 2 = "2"
Integer/show +2 = "+2"
Integer/show -2 = "-2"
Migration
To migrate code you need to:
Remove the leading
+
from allNatural
number literalsAdd a leading
+
to all non-negativeInteger
literalsReplace
Natural/show n
with"+${Natural/show n}"
Replace
Integer/show (Natural/toInteger n)
withNatural/show n
Also, you can no longer render Integer
s without a leading +
or -
sign