lua-users home
lua-l archive

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


On 2010-02-25 00:53, Nevin Flanagan wrote:
[...]
Does this mean that you can supply any value to _ENV, as long as it provides __index and __newindex metamethods as required?

Hmm. If I'm *not* using globals, can I assign nil to _ENV to get runtime errors if I tyop the name of a local?

local string_len = string.len
_ENV = nil
a = 5 -- oops, forgot to local this

Is there any chance of a facility to produce *compile* time errors if my code tries to reference globals? It would have to be possible to turn it on halfway through a chunk, once I'd finished loading locals from the global table (as in the example above).

This would be invaluable for large programs; tracking down typo'd variable names is a suprisingly large portion of my debugging time.

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL