you can change the metatable of nil to get that behavior.
terrifying and clever :)
clearly, i haven't been paying enough attention to the trouble one can cause with with debug.setmetatable :)
i'm not entirely convinced it's wise. there are moments in my life when emitting an error because of missing data is a good thing. but it's certainly useful to know there's a way to get this behavior without resorting to parser hacks.
There are two flavours.
first = function(a,b) return a end
second = function(a,b) return b end
do you have a use case in mind for the second option? i'm having a hard time imagining a situation where i'd want to return the key in the case of an index into an undefined table -- though maybe i'm missing something :)
-Sven