var
: mutable variables
This is for variables whose value can be modified after initialization:
Take a look at the var statement in the manual.
let
: immutable variables
Even better to use let
when we don't expect that a variable will change. Modifications will be detected at compile time:
Nim supports three different types of variables, let
, var
, and const
. As with most things, multiple variables can be declared in the same section.
Const
A const variable’s value will be evaluated at compile-time, so if you inspect the C sources, you’ll see the following line:
The only limitation with const is that compile-time evaluation cannot interface with C because there is no compile-time foreign function interface at this time.