lua-users home
lua-l archive

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


On Sun, May 9, 2010 at 4:36 PM, Klaus Ripke <paul-lua@malete.org> wrote:
> Could indexing anything but a table, or at least indexing nil,
> return nil instead of throwing an error?
> I don't see why x.z conveniently gives nil, if there is no z in x,
> but x.y.z requires an extra check for x.y .
> This makes working with structures with lots of optional parts pretty
> tedious - and if it's external input, basically everything is optional.

If you want this, then you can already get it in 5.1 by doing:
debug.setmetatable(nil, {__index = {}})