On May 12, 2020, at 4:49 PM, Andrea <andrea.l.vitali@gmail.com> wrote:
thank you for your example - and just to be clear: I am perfectly fine with "local by default" and would not change anything in Lua
my comment for your example below is that there is still some asymmetry:
the "global" in read is optional, nothing changes if omitted;
on the opposite the "global" in write is mandatory, does not work as intended if omitted
function read()
global x
return x
end
function write()
global x
x = 1
end
My proposal is that leaving out global x would be a load error, i.e. either local or global would be required, for every variable.
The issue is, people generally don’t like typing that much and they don’t like being forced to make decisions about scope when everything can just be global. I personally feel differently, so typing a bit more isn’t so bad.
|