lua-users home
lua-l archive

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

One approach to introduce global/local without breaking old
code or habits might be to have two keywords for function 

A function declared with the "function" keyword would
continue to behave as it always has.

A function declared with another keyword (say, "fun"
or "proc") would use the new semantics, and only in 
that context would the "global" keyword be valid.

This would also allow people who prefer the old semantics
(say, for writing configuration files) to keep using them.
The documentation could describe the more error-prone
"function" as deprecated and discourage its use.

To help with converting old code, the interpreter
might warn about any use of the "function" keyword when
run with a special flag.  Of course, any new keyword
may break a small percentage of old code; for full backwards
compatibility, another flag could turn off recognition of 
the new keyword.