- The stdlib module
future
has been renamed tosugar
. macros.callsite
is now deprecated. Since the introduction ofvarargs
parameters this became unnecessary.- Anonymous tuples with a single element can now be written as
(1,)
with a trailing comma. The underlying AST isnnkTupleConst(newLit 1)
for this example.nnkTupleConstr
is a new node kind your macros need to be able to deal with! - Indexing into a
cstring
for the JS target is now mapped tocharCodeAt
. - Assignments that would "slice" an object into its supertype are now prevented
at runtime. Use
ref object
with inheritance rather thanobject
with inheritance to prevent this issue. - The
not nil
type annotation now has to be enabled explicitly via{.experimental: "notnil"}
as we are still not pleased with how this feature works with Nim's containers. - The parser now warns about inconsistent spacing around binary operators as these can easily be confused with unary operators. This warning will likely become an error in the future.
- The
'c
and'C'
prefix for octal literals is now deprecated to bring the language in line with the standard library (e.g.parseOct
).
-
re.split
for empty regular expressions now yields every character in the string which is what other programming languages chose to do. -
The returned tuple of
system.instantiationInfo
now has a third field containing the column of the instantiation. -
cookies.setCookie
no longer assumes UTC for the expiration date. -
strutils.formatEng
does not distinguish betweennil
and""
strings anymore for itsunit
parameter. Instead the space is controlled by a new parameteruseUnitSpace
. -
proc `-`*(a, b: Time): int64
in thetimes
module has changed return type totimes.Duration
in order to support higher time resolutions. The proc is no longer deprecated. -
posix.Timeval.tv_sec
has changed type toposix.Time
. -
math.`mod`
for floats now behaves the same asmod
for integers (previously it used floor division like Python). Usemath.floorMod
for the old behavior. -
For string inputs,
unicode.isUpper
andunicode.isLower
now require a second mandatory parameterskipNonAlpha
. -
For string inputs,
strutils.isUpperAscii
andstrutils.isLowerAscii
now require a second mandatory parameterskipNonAlpha
. -
osLastError
is now marked withsideEffect
-
The procs
parseHexInt
andparseOctInt
now fail on empty strings and strings containing only valid prefixes, e.g. "0x" for hex integers. -
terminal.setCursorPos
andterminal.setCursorXPos
now work correctly with 0-based coordinates on POSIX (previously, you needed to use 1-based coordinates on POSIX for correct behaviour; the Windows behaviour was always correct).
- The undocumented
#? braces
parsing mode was removed. - The undocumented PHP backend was removed.
re.split
now also supports themaxsplit
parameter for consistency withstrutils.split
.- Added
system.toOpenArray
in order to support zero-copy slicing operations. This is currently not yet available for the JavaScript target. - Added
getCurrentDir
,findExe
,cpDir
andmvDir
procs tonimscript
. - The
times
module now supports up to nanosecond time resolution when available. - Added the type
times.Duration
for representing fixed durations of time. - Added the proc
times.convert
for converting between different time units, e.g days to seconds. - Added the proc
algorithm.binarySearch[T, K]
with thecmp
parameter. - Added the proc
algorithm.upperBound
. - Added inverse hyperbolic functions,
math.arcsinh
,math.arccosh
andmath.arctanh
procs. - Added cotangent, secant and cosecant procs
math.cot
,math.sec
andmath.csc
; and their hyperbolic, inverse and inverse hyperbolic functions,math.coth
,math.sech
,math.csch
,math.arccot
,math.arcsec
,math.arccsc
,math.arccoth
,math.arcsech
andmath.arccsch
procs. - Added the procs
math.floorMod
andmath.floorDiv
for floor based integer division. - Added the procs
rationals.`div```,
rationals.`mod```,rationals.floorDiv
and ``rationals.floorMod`` for rationals. - Added the proc
math.prod
for product of elements in openArray. - Added the proc
parseBinInt
to parse a binary integer from a string, which returns the value. parseOct
andparseBin
in parseutils now also support themaxLen
argument similar toparseHexInt
- Added the proc
flush
for memory mapped files. - Added the
MemMapFileStream
.
macros.astGenRepr
,macros.lispRepr
andmacros.treeRepr
now escapes the content of string literals consistently.macros.NimSym
andmacros.NimIdent
is now deprecated in favor of the more generalNimNode
.macros.getImpl
now includes the pragmas of types, instead of omitting them.macros.hasCustomPragma
andmacros.getCustomPragmaVal
now also supportref
andptr
types, pragmas on types and variant fields.system.SomeReal
is now calledSomeFloat
for consistency and correctness.algorithm.smartBinarySearch
andalgorithm.binarySearch
is now joined inbinarySearch
.smartbinarySearch
is now deprecated.- The
terminal
module now exports additional procs for generating ANSI color codes as strings. - Added the parameter
val
for theCritBitTree[int].inc
proc. - An exception raised from a
test
block ofunittest
now shows its type in error message. - The
compiler/nimeval
API was rewritten to simplify the "compiler as an API". Using the Nim compiler and its VM as a scripting engine has never been easier. Seetests/compilerapi/tcompilerapi.nim
for an example of how to use the Nim VM in a native Nim application. - Added the parameter
val
for theCritBitTree[T].incl
proc. - The proc
tgamma
was renamed togamma
.tgamma
is deprecated. - The
pegs
module now exports getters for the fields of itsPeg
andNonTerminal
object types.Peg
s with child nodes now have the standarditems
andpairs
iterators.
- Dot calls combined with explicit generic instantiations can now be written
as
x.y[:z]
which is transformed intoy[z](x)
by the parser. func
is now an alias forproc {.noSideEffect.}
.- In order to make
for
loops and iterators more flexible to use Nim now supports so called "for-loop macros". See themanual <manual.html#macros-for-loop-macros>
_ for more details. - the
typedesc
special type has been renamed to justtype
. static
andtype
are now also modifiers similar toref
andptr
. They denote the special typesstatic[T]
andtype[T]
.- Forcing compile-time evaluation with
static
now supports specifying the desired target type (as a concrete type or as a type class) - The
type
operator now supports checking that the supplied expression matches an expected type constraint.
-
The
importcpp
pragma now allows importing the listed fields of generic C++ types. Support for numeric parameters have also been added through the use ofstatic[T]
types. (#6415) -
Native C++ exceptions can now be imported with
importcpp
pragma. Imported exceptions can be raised and caught just like Nim exceptions. More details in language manual. -
nil
for strings/seqs is finally gone. Instead the default value for these is"" / @[]
. -
Accessing the binary zero terminator in Nim's native strings is now invalid. Internally a Nim string still has the trailing zero for zero-copy interoperability with
cstring
. Compile your code with the new switch--laxStrings:on
if you need a transition period. -
The command syntax now supports keyword arguments after the first comma.
-
Thread-local variables can now be declared inside procs. This implies all the effects of the
global
pragma. -
Nim now supports
except
clause in the export statement. -
Range float types, example
range[0.0 .. Inf]
. More details in language manual.
jsondoc2
has been renamedjsondoc
, similar to howdoc2
was renameddoc
. The oldjsondoc
can still be invoked withjsondoc0
.
-
The VM's instruction count limit was raised to 1 billion instructions in order to support more complex computations at compile-time.
-
Support for hot code reloading has been implemented for the JavaScript target. To use it, compile your code with
--hotCodeReloading:on
and use a helper library such as LiveReload or BrowserSync. -
A new compiler option
--cppCompileToNamespace
puts the generated C++ code into the namespace "Nim" in order to avoid naming conflicts with existing C++ code. This is done for all Nim code - internal and exported. -
Added
macros.getProjectPath
andospaths.putEnv
procs to Nim's virtual machine. -
The
deadCodeElim
option is now always turned on and the switch has no effect anymore, but is recognized for backwards compatibility. -
experimental
is now a pragma / command line switch that can enable specific language extensions, it is not an all-or-nothing switch anymore. -
Nintendo Switch was added as a new platform target. See the compiler user guide for more info.