Every parameter in Nim is immutable unless it is declared as a var parameter.
This means that the following code does not compile:
proc resetPointsToOrigin(points: seq[Point]) =
for i in 0 ..< points.len: # 1
points[i] = Point(x: 0, y: 0) # 2
The compiler rejects the code because points is a parameter that can only be used for read accesses. This restriction helps us to write code that is easier to understand and scales better to larger programs and at the same time it helps the compiler to produce better machine code.
In order to be allowed to mutate points we need a var parameter:
proc resetPointsToOrigin(points: var seq[Point]) = # 1
for i in 0 ..< points.len:
points[i] = Point(x: 0, y: 0) # 2
If we now try to call resetPointsToOrigin with a seq constructor the compiler once again rejects our code:
resetPointsToOrigin @[Point(x: 2, y: 4)]
The reason is that a sequence constructed via @[] is not mutable. A variable is mutable, so the following is valid:
var points = @[Point(x: 2, y: 4)]
resetPointsToOrigin points