Best location to declare variables in a proc

2024-08-04 Thread khaledh-nim
> 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

Best location to declare variables in a proc

2024-08-04 Thread xigoi
Why not just do this? proc testProc() = for i in 0..100: let j = $i Run

Best location to declare variables in a proc

2024-08-04 Thread Hobbyman
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

Best location to declare variables in a proc

2024-08-03 Thread stbalbach
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