lua-users home
lua-l archive

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


On Fri, Mar 1, 2013 at 1:31 PM, Eike Decker <zet23t@googlemail.com> wrote:
> Have you considered metatable trickery?

Or just messing with nil's metatable, as lhf once suggested?

debug.setmetatable(nil,{
    __index = function(t,k) return nil end
})

a = {}

print(a.b.c)
-->
nil

Evil and cunning; in an ideal world, a module writer could mess with
one of the standard metatables and this would _only_ apply to that
environment. A _relatively_ benign global adjustment, but one that
makes a common class of error more obscure.

steve d.