Pr0f wrote:it does look messy - being able to amend a variable that's been declared as local, and being allowed to do so because you are being called by the procedure that declared it local. It's more regional then
Yes, depending upon the language (and its implementation) there are these two definitions of 'local' that have different 'lexical' scopes - namely:
a) Within only the most immediate definition where the LOCal is defined: referred to as 'static' scope - typically adopted in modern compiled languages, or else
b) Scoped within this definition AND all definitions called from here: referred to as 'dynamic' scope - which is how S*Basic applies the definition and which apparently takes much of its methodology from older languages such as Lisp.
I personally find S*Basic's dynamic scoping more helpful so as to reduce the amount of parameter passing (as a means of localising variables) needed. It does take some planning however to avoid tampering with similarly named variables within a chain of FNs/PROCs.