This is fine of course:
proc p1(pi: ptr int) =
pi[] = 7
proc p2(pi: ptr int) =
p1(pi)
var x = create(int)
p2(x)
echo x[]
But I did not expect that this would compile:
proc p3(i: var int) =
i = 13
proc p4(pi: ptr int) =
p3(cast[var int](pi))
var y = create(int)
p4(y)
echo y[]
On the other hand, var proc parameters are basically pointers, so maybe I should be not surprised. That type of casting can be useful for C wrappers, when we have a C pointer and want to call a Nim proc with a var parameter...