lua-users home
lua-l archive

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


On Dec 14, 2010, at 10:22 AM, Roberto Ierusalimschy wrote:

>> The problem is that nil is both a value that can be useful in
>> computations and the representation of non-presence in a table. Mostly
>> that's okay. When it isn't, code can break in surprising ways if one
>> hasn't thought ahead.
> 
> Of course, the fact that "code can break in surprising ways if one
> hasn't thought ahead" is true for almost any code :)

True. I guess it's more the issue that Lua has a number of more or less standard idioms that almost work until confronted with nil and so you can write idiomatic code that will be fine until you hit the case it doesn't handle and that doesn't generally get called out as not handled in descriptions of the idiom.

Similarly, the ternary operator comes up repeatedly as well because "a and b or c" is only mostly correct as an implementation of the construct.

Mark