lua-users home
lua-l archive

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


> I repeat that I do not consider the current scoping an issue.  The
> "globals.lua" and "undefined.lua" scripts provide ample security IMO.
> But if it had to change, I'd vote for "_localname", and eventually
> dropping the "local" reserved word.

Naturally, many people (including myself) wouldn't favour this one based
purely on the total distaste of having a naming convention of any type
forced on them. This is like saying that since most people in C #define
constants that are all upper case, why not remove the const keyword and just
say that if you want something to be const, make it's name all uppercase,
and it magically will be.

As for my own idea lots of people will hate:

- introduce global as a keyword to make a variable global
- leave the current defaults alone
- introduce a new mode where variables must be explicitely declared before
being used
- make the new mode swtichable either by a compile-time flag or a command
line parameter

Any existing code would have to be modified to run in the new mode. But
anyone who has a lot of existing code and is happy with how things work
wouldn't have to bother turning on that flag. People who are well and truly
paranoid about bugs involved when you accidentally access a global(such as
myself) can turn the magic mode on during development, making sure that
everything works properly. It could then run even under the non-magic mode
as is. Anyone who thinks it's a good idea isn't allowed to complain that
they have to explicitely declare variables instead of just using them, and
get to say that it makes the program's intent much clearer.People that don't
think it's a good idea can use the other methods to get the job done.