lua-users home
lua-l archive

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


Would Roberto maybe admit that if he was redesigning Lua from scratch today variables would be local by default and global by declaration? If not, why not?

No. It is simply wrong.

Why? It seems to me that, with lexically scoped local variables, the use of Globals other than for extending or customising the language or publishing libraries is lazy and should always be something the programmer has to think about and justify. If you are going to have automatic variables, their scope should be as restricted as possible. The global table is always an interface between programmers - between the application being scripted, or between multiple scripters in the same environment. At present it is much too easy for one programmer to accidentally undermine another's work or break the programming environment. I accept and value that Lua uses a trust model for containment, but it is still better for "the right thing" to be easy to do and "the wrong thing" to require some thought.