- The stdlib module
futurehas been renamed tosugar. macros.callsiteis now deprecated. Since the introduction ofvarargsparameters 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.nnkTupleConstris a new node kind your macros need to be able to deal with! - Indexing into a
cstringfor the JS target is now mapped tocharCodeAt. - Assignments that would "slice" an object into its supertype are now prevented
at runtime. Use
ref objectwith inheritance rather thanobjectwith inheritance to prevent this issue. - The
not niltype 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.
-
re.splitfor empty regular expressions now yields every character in the string which is what other programming languages chose to do. -
The returned tuple of
system.instantiationInfonow has a third field containing the column of the instantiation. -
``cookies.setCookie` no longer assumes UTC for the expiration date.
-
strutils.formatEngdoes not distinguish betweenniland""strings anymore for itsunitparameter. Instead the space is controlled by a new parameteruseUnitSpace. -
proc `-`*(a, b: Time): int64in thetimesmodule has changed return type totimes.Durationin order to support higher time resolutions. The proc is no longer deprecated. -
posix.Timeval.tv_sechas changed type toposix.Time.
- The undocumented
#? bracesparsing mode was removed. - The undocumented PHP backend was removed.
re.splitnow also supports themaxsplitparameter for consistency withstrutils.split.- Added
system.toOpenArrayin order to support zero-copy slicing operations. This is currently not yet available for the JavaScript target. - Added
getCurrentDir,findExe,cpDirandmvDirprocs tonimscript. - The
timesmodule now supports up to nanosecond time resolution when available. - Added the type
times.Durationfor representing fixed durations of time. - Added the proc
times.convertfor converting between different time units, e.g days to seconds.
macros.astGenRepr,macros.lispReprandmacros.treeReprnow escapes the content of string literals consistently.macros.NimSymandmacros.NimIde 4E8E ntis now deprecated in favor of the more generalNimNode.macros.getImplnow includes the pragmas of types, instead of omitting them.macros.hasCustomPragmaandmacros.getCustomPragmaValnow also supportrefandptrtypes, pragmas on types and variant fields.system.SomeRealis now calledSomeFloatfor consistency and correctness.algorithm.smartBinarySearchandalgorithm.binarySearchis now joined inbinarySearch.smartbinarySearchis now deprecated.- The
terminalmodule now exports additional procs for generating ANSI color codes as strings.
- Dot calls combined with explicit generic instantiations can now be written
as
x.y[:z].x.y[:z]that is transformed intoy[z](x)in the parser. funcis now an alias forproc {.noSideEffect.}.- In order to make
forloops 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
importcpppragma 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
importcpppragma. Imported exceptions can be raised and caught just like Nim exceptions. More details in language manual. -
nilfor 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:onif 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
globalpragma. -
Nim now supports
exceptclause in the export statement.
jsondoc2has been renamedjsondoc, similar to howdoc2was renameddoc. The oldjsondoccan 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:onand use a helper library such as LiveReload or BrowserSync. -
A new compiler option
--cppCompileToNamespaceputs 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.getProjectPathandospaths.putEnvprocs to Nim's virtual machine. -
The
deadCodeElimoption is now always turned on and the switch has no effect anymore, but is recognized for backwards compatibility. -
experimentalis now a pragma / command line switch that can enable specific language extensions, it is not an all-or-nothing switch anymore.