Nim 1.5.0 Programming Language

After the year of development Published Release of the System Programming Language NIM 1.5 , which uses static typing and created with a loan on Pascal, C ++, Python and Lisp. The source code in the NIM language is compiled into the view on C, C ++ or JavaScript. In the future, the C / C ++ code is compiled into the executable file using any available compiler (CLANG, GCC, ICC, VISUAL C ++), which makes it possible to achieve the performance close to C, if you do not take into account the costs of the garbage collector. By analogy with Python in NIM, indents are applied as block separators. Metaprogramming and ability to create subject-oriented languages ​​(DSL) are supported. Project code comes under license MIT.

Among noticeable changes in a new release:

  • Added class ITERABLE [T] with Sales type for iterators. TEMPLATE SUM [T] (A: Iterable [T]): T = Var Result: T for ai in a: result + = ai Result Assert Sum (IOTA (3)) == 0 + 1 + 2 # or ‘IOTA ( 3) .sum ‘
  • Annotations support added “ .effectsof ” for selective use effects . WHEN DEFINED (NIMHASEFFECTSOF): {.experimental: “stricteffects”.} else: {.Pragma: Effectsof.} Proc Mysort (S: SEQ; CMP: Proc (A, B: T): INT) {.effectsof: CMP. }
  • A new import syntax “Import Foo {islall}” is proposed, which allows you to import not only public, but also private characters. To access private fields of objects, the STD / Importutils and API PRIVATEACCESS module has been added. from System {.all.} AS System2 Import Nil Echo System2.Thisisystem Import OS {.all.} Echo WeirdTarget
  • added experimental support for operators starting from the point that can be used to implement dynamic fields. Import STD / JSON template ‘?’ (A: JSONNODE, B: Untyped {Ident}): jsonnode = a [asttostr (b)] Let j =% * {“A1”: {“A2”: 10}} Assert J.?a1.?a2.getint == 10
  • in the block arguments is allowed to specify additional parameters. Template Fn (A = 1, B = 2, BODY1, BODY2) = DISCARD FN (A = 1): BAR1 DO: BAR2
  • implemented support for the literals defined by the user (for example, “-128’Bignum ‘). func ” big ‘* (num: cstring): JsBigInt {.importjs: “BigInt (#)”.} assert 0xffffffffffffffff’big == (1’big shl 64’big) – 1’big
  • The compiler implements the “–EVAL: CMD” command to directly launch commands in the NIM language from the command line, for example ‘Nim –eval: “ECHO 1″‘.
  • provided support for creating their own extensions for the Nimscript backend.
  • Early error messages are significantly expanded in which the context associated with an error is provided. Custom compiler warnings are implemented.
  • Significantly improved work of garbage collectors “–GC: ARC” and “–GC: ORC”.
/Media reports.