Reusing variables or strings in Functions inside Functions

I am writing a function where I call other functions from within the main function. I am not using static/structures and I don't have global variables or strings. I am wondering if it is safe to reuse local variables or strings in the other functions? I should know the answer to this but I'm not 100% sure.

In my limited testing it seems OK for example to have a loop using variable i and to call another function within that loop that also uses i. The two variable are treated independently by Igor. Is this correct?
Your observations are correct!

All local variables, strings, structs (objects) which are not passed-by-reference to other functions can only be accessed/changed in that function. Global objects (global variables/strings, non-free waves, non-free datafolders) are surviving the end of a function run (they are "persistent").

Function MyFuncLocal()
    variable counter
    string str
 
    counter = NaN
    str     = "Hi there"
 
    AnotherFuncLocal()
End
 
Function AnotherFuncLocal()
 
    variable counter
    string str
 
    print counter
    print strlen(str)
 
End
 
Function FuncWithGlobalObjects()
 
    variable/G counter
 
    counter = 4711
    
    AnotherFuncWithGlobalObjects()
End
 
Function AnotherFuncWithGlobalObjects()
 
    NVAR counter
    print counter
End
 
Function MyFuncLocalPassByRef()
    variable counter
    string str
 
    counter = NaN
    str     = "Hi there"
 
    print counter
    AnotherFuncLocalPassByRef(counter)
    print counter
End
 
Function AnotherFuncLocalPassByRef(counter)
    variable &counter
 
    counter = 0
End


•MyFuncLocal()
  0
  NaN
•FuncWithGlobalObjects()
  4711
•MyFuncLocalPassByRef()
  NaN
  0