-
The
Math.trunc
polyfill for targeting Internet Explorer was previously emitted for every JavaScript output file except if the symbolnodejs
was defined via-d:nodejs
. Now, it is only emitted if the symbolnimJsMathTruncPolyfill
is defined. If you are targeting Internet Explorer, you may choose to enable this option or define your ownMath.trunc
polyfill using theemit
pragma. Nim usesMath.trunc
for the division and modulo operators for integers. -
Deprecated
std/sums
. -
Optional parameters in combination with
: body
syntax (RFC #405) are now opt-in viaexperimental:flexibleOptionalParams
. -
std/sharedstrings
module is removed. -
Constants
colors.colPaleVioletRed
andcolors.colMediumPurple
changed to match the CSS color standard. -
addr
is now available for all addressable locations,unsafeAddr
is deprecated and becomes an alias foraddr
. -
io
andassertions
are about to move out of system; use-d:nimPreviewSlimSystem
, importstd/syncio
and importstd/assertions
. -
The
gc:v2
option is removed. -
The
threads:on
option becomes the default.
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). md5
now works at compile time and in JavaScript.std/smtp
sendsehlo
first. If the mail server does not understand, it sendshelo
as a fallback.- Changed mimedb to use an
OrderedTable
instead ofOrderedTableRef
, to use it in a const. strutils.find
now use and default tolast=-1
for whole string searches, making limiting it to just the first char (last=0
) valid.random.rand
now works withOrdinal
s.
- Added
IsoWeekRange
, a range type to represent the number of weeks in an ISO week-based year. - Added
IsoYear
, a distinct int type to prevent bugs from confusing the week-based year and the regular year. - Added
initDateTime
intimes
to create a datetime from a weekday, and ISO 8601 week number and week-based year. - Added
getIsoWeekAndYear
intimes
to get an ISO week number along with the corresponding ISO week-based year from a datetime. - Added
getIsoWeeksInYear
intimes
to return the number of weeks in an ISO week-based year. - Added
std/oserrors
for OS error reporting. Addedstd/envvars
for environment variables handling. - Added
sep
parameter instd/uri
to specify the query separator. - Added
Array.shift
for JavaScript targets. - Added
queueMicrotask
for JavaScript targets.
- Deprecated
selfExe
for Nimscript.
- Removed deprecated
oids.oidToString
. - Removed define
nimExperimentalAsyncjsThen
forstd/asyncjs.then
andstd/jsfetch
. - Removed deprecated
jsre.test
andjsre.toString
. - Removed deprecated
math.c_frexp
. - Removed deprecated
httpcore.`==`
. - Removed deprecated
std/dom_extensions
. - Removed deprecated
std/posix.CMSG_SPACE
andstd/posix.CMSG_LEN
that takes wrong argument types. - Removed deprecated
osproc.poDemon
, symbol with typo.
-
Case statement macros are no longer experimental, meaning you no longer need to enable the experimental switch
caseStmtMacros
to use them. -
Templates now accept macro pragmas.
-
Macro pragmas for var/let/const sections have been redesigned in a way that works similarly to routine macro pragmas. The new behavior is documented in the experimental manual.
-
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
-
Full command syntax and block arguments i.e.
foo a, b: c
are now allowed for the right-hand side of type definitions in type sections. Previously they would error with "invalid indentation". -
defined
now accepts identifiers separated by dots, i.e.defined(a.b.c)
. In the command line, this is defined as-d:a.b.c
. Older versions can use accents as indefined(`a.b.c`)
to access such defines. -
Defines the
gcRefc
symbol which allows writing specific code for the refc GC.
-
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.