Well, couldn't you just (I mean, "just") program a sort of preprocessor which looks for such lines:
static varname (as vartype) (= value)
within functions and as consequence automatically renames them for this function by using the functionname as prefix?
For instance, this code
function Test()
local myVar as integer = 5
inc myVar2
inc myVar
print myVar,"/",myVar2
endfunction
...would be changed to this:
rem Very beginning of your code
global Test_myVar as integer = 5
...
function Test()
inc myVar2
inc Test_myVar
print Test_myVar,"/",myVar2
endfunction
This way you would not need to use more commands within your function, you would not need to write longer variable-names and the program would not be slower in any way (I guess). The only disadvantages are, that your compiletime would be a bit higher (depending on the programming language used for the preprocessor something between nothing and ~two seconds or so) and that this method is not totally save (Typing Test_myVar manually somewhere in the code would access the static variable from outside the function)... even though a possible solution for the preprocessor would be renaming all variables _containing_ the name, so "myVar" inside the function would be changed to "Test_MyVar" and all variable containing "myVar" outside the function would get a "main_"-prefix or so... however, could become quite complicated on this level. Still, is my basic idea actually right? Or did I misunderstand something?
Edit: I'm just wondering why my [*code*]-tag (without stars of course) doesn't work.... it always used to, am I doing something wrong?
[MOD EDIT - IanM]Yes, the last code tag didn't contain the leading slash.