lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Globals-backslashed style should be optional.
And then you have to convert code parts when you move them between files of a single code base.

While I would like to have nothing by default, I don't like this solution at all. It changes every single access to globals. Also while it solves typos when accessing locals the compiler still doesn't check any access of globals when using \.

Roberto once suggested that globals have to be declared as well. So you have to declare which globals you want to use, and if you declare no globals at all, Lua would act like it does now (allow any access).

I have some ideas that something like a compiler pragma or a declaration block would work nicely. But they are just random ideas. I think others have suggested this already. Something like

local print = print
local t = {}
table.insert(t, 1) -- OK
local do - -"do local" would be less yoda speak but I think that is already valid syntax
    print "hello" -- OK
    table.insert(t, 1) -- error table isn't local
end
table.insert(t, 1) -- OK

--
Thomas