Questions about Variables, Scope, and Concurrent Access

Isn't that the same issue in many languages, like JavaScript?

IOW, it is up to the developer to properly declare his/her variables.

While I don't want the language to use a naming convention, I often have.
So any variable I declare local, I have used a prefix of "l" or "l_" (that's a lower case L). This helps to remind me.

The other approach, that I have taken with AppleScript, is to use a naming convention for script properties (which are global, and persist between executions), like "pty", and for global variables, like"g".

Here's an AppleScript example:

global gX

set gX to 1000
set localX to 5
set y to my testLocal(100)
log localX
-->5

log gX
-->2000

on testLocal(pVar)
  set localX to 10 -- the var "localX" in the main script is not changed
  set gX to 2000 -- the var "gX" in the main script IS changed
  return pVar + 1
end testLocal