-
addr
is now available for all addressable locations,unsafeAddr
is now deprecated and an alias foraddr
. -
io
,assertions
,formatfloat
, anddollars.`$`
for objects are about to move out of thesystem
module. You may instead importstd/syncio
,std/assertions
,std/formatfloat
andstd/objectdollar
. The-d:nimPreviewSlimSystem
option makes these imports required. -
The
gc:v2
option is removed. -
The
mainmodule
andm
options are removed. -
The
threads:on
option is now the default. -
Optional parameters in combination with
: body
syntax (RFC #405) are now opt-in viaexperimental:flexibleOptionalParams
.
-
Pointer to
cstring
conversion now triggers a[PtrToCstringConv]
warning. This warning will become an error in future versions! Use acast
operation likecast[cstring](x)
instead. -
logging
will default to flushing all log level messages. To get the legacy behaviour of only flushing Error and Fatal messages, use-d:nimV1LogFlushBehavior
. -
Object fields now support default values, see https://nim-lang.github.io/Nim/manual.html#types-default-values-for-object-fields for details.
-
Redefining templates with the same signature was previously allowed to support certain macro code. To do this explicitly, the
{.redefine.}
pragma has been added. Note that this is only for templates. Implicit redefinition of templates is now deprecated and will give an error in the future. -
Using an unnamed break in a block is deprecated. This warning will become an error in future versions! Use a named block with a named break instead.
-
Several Standard libraries are moved to nimble packages, use
nimble
to install them:std/punycode
=>punycode
std/asyncftpclient
=>asyncftpclient
std/smtp
=>smtp
std/db_common
=>db_connector/db_common
std/db_sqlite
=>db_connector/db_sqlite
std/db_mysql
=>db_connector/db_mysql
std/db_postgres
=>db_connector/db_postgres
std/db_odbc
=>db_connector/db_odbc
-
Previously, calls like
foo(a, b): ...
orfoo(a, b) do: ...
where the final argument offoo
had typeproc ()
were assumed by the compiler to meanfoo(a, b, proc () = ...)
. This behavior is now deprecated. Usefoo(a, b) do (): ...
orfoo(a, b, proc () = ...)
instead. -
If no exception or any exception deriving from Exception but not Defect or CatchableError given in except, a
warnBareExcept
warning will be triggered.
macros.parseExpr
andmacros.parseStmt
now accept an optional filename argument for more informative errors.- Module
colors
expanded with missing colors from the CSS color standard. - Fixed
lists.SinglyLinkedList
being broken after removing the last node (#19353).
-
Pragma macros on type definitions can now return
nnkTypeSection
nodes as well asnnkTypeDef
, allowing multiple type definitions to be injected in place of the original type definition.import macros macro multiply(amount: static int, s: untyped): untyped = let name = $s[0].basename result = newNimNode(nnkTypeSection) for i in 1 .. amount: result.add(newTree(nnkTypeDef, ident(name & $i), s[1], s[2])) type Foo = object Bar {.multiply: 3.} = object x, y, z: int Baz = object # becomes type Foo = object Bar1 = object x, y, z: int Bar2 = object x, y, z: int Bar3 = object x, y, z: int Baz = object
-
Case statement macros are no longer experimental, meaning you no longer need to enable the experimental switch
caseStmtMacros
to use them.
-
nim
can now compile version 1.4.0 as follows:nim c --lib:lib --stylecheck:off compiler/nim
, without requiring-d:nimVersion140
which is now a noop. -
--styleCheck
now only applies to the current package.
-
The
gc
switch has been renamed tomm
("memory management") in order to reflect the reality better. (Nim moved away from all techniques based on "tracing".) -
Nim now supports Nimble version 0.14 which added support for lock-files. This is done by a simple configuration change setting that you can do yourself too. In
$nim/config/nim.cfg
replacepkgs
bypkgs2
. -
There is a new switch
--nimMainPrefix:prefix
to influence theNimMain
that the compiler produces. This is particularly useful for generating static libraries.