lua-users home
lua-l archive

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


PA wrote:

On Aug 21, 2007, at 18:05, Mark Hamburg wrote:

What I'd like to see is support for something like:

    t.foo?.baz

What about:

debug.setmetatable( nil, { __index = function( self, aKey ) return nil end } )

print( t.foo.baz )

 > nil




I don't think it quite "do the trick" because this would cause all nil's to be somewhat indexable (i.e. don't cause error). Mark proposed a way to declare that this (don't cause error, just return nil) was your intent for a particular situation.

--rb