> There is overhead to create and destroy a variable 100 times.
I tested this, and it seems that the variable memory location (on the stack) is
reused; i.e. the space is reserved for it once on the stack.
Note: Keep in mind that string objects store a pointer to the actual string
data on the he
Why not just do this?
proc testProc() =
for i in 0..100:
let j = $i
Run
I still wanted to test if that would even work. I confirm it does.
Good to know.
>From my perspective:
Con:
* unneeded handling/cost as compared to declaring outside of loop.
* the var can only be used for one pass after which it is reset.
Pro:
* advantage for refactoring and ease of
Is it better to declare variables at the start of a proc, or closer to where
needed?
Thinking about loops
proc testProc() =
for i in 0..100:
var j = ""
j = $i
Run
There is overhead to create and destroy a variable 100 times. Yet, program best
pr