5

Is there any constant variable or proc that allows to access the compiler version as a string or number?

Jundiaius
  • 6,214
  • 3
  • 30
  • 43

1 Answers1

7

The version can be obtained as a string via system.NimVersion (remember that system is implicitly imported):

echo NimVersion # 0.18.0

You can also access its component parts (MAJOR.MINOR.PATCH) as numbers like so:

echo NimMajor # 0
echo NimMinor # 18
echo NimPatch # 0

This makes checking versions for compatibility very easy when combined with tuples:

when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0):
  echo "we're on at least Nim v0.19.0"
haltcase
  • 3
  • 2
Jundiaius
  • 6,214
  • 3
  • 30
  • 43