[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: In praise of 'nil' (Was: Proposal for table length operator
- From: Dirk Laurie <dpl@...>
- Date: Wed, 15 Dec 2010 08:01:29 +0200
On Wed, Dec 15, 2010 at 06:28:30AM +0200, Mark Hamburg wrote:
> 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.
It is a tribute to the thoughtfulness with which the behaviour of nil
has been designed that very often one does not need to test for it.
It is a beautiful philosophical concept.
What happened before the Big Bang? Nil.
And nobody, really nobody, stops you from writing
if a==nil then
when you can't think of a more elegant (but probably more
obfuscated) way to do what you mean.
Dirk