Three years after the official release of Nim 1, Nim 2 RC is finally here. One of the goals of Nim 2 is to make it easier for developers to write code that is compatible with both versions (Nim 1 and 2), the announcement reads. Many important packages are currently available in Nim 2. Additionally, Nim 2 adds “switches” for innovative features that can be enabled or disabled at the module level.

According to the official statement, Nim 2 is based on the same code base as Nim 1, and Nim 2 is an evolution of Nim 1, not a huge change.

Major new features in Nim 2

  • The default memory policy is changed to:--mm:orc

For specific examples, see: A cost model for Nim or Introduction to ARC/ORC in Nim.

  • Add Overloadable enums

Overloadable enums are out of experimental phase, usage example:


  type
    E1 = enum
      value1, value2
    E2 = enum
      value1, value2 = 4

  const
    Lookuptable = [
      E1.value1: "1",
      value2: "2"
    ]
  • Strict funcs

“strict funcs” have reached a stable state and will become the default option in a future release.

Default values ​​are now supported in object declaration fields:


  type
    Rational* = object
      num: int = 0
      den: int = 1

  var r = Rational()
  assert $r == "(num: 0, den: 1)"

Nim 2 will enable by default--experimental:unicodeOperators: such asβŠ—or∘The Unicode operator support is used by the math library. Note that the standard library does not use Unicode operators.

See the announcement for details.

#Nim #released #compatible #Nim #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *