[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Depth indexing of nil
- From: Scott Morgan <blumf@...>
- Date: Thu, 09 Jul 2015 13:15:18 +0100
On 09/07/15 02:10, Simon Green wrote:
> if a.b.c.d.e == something then something-else end
>
> only works if everything down to e exists. If anything else doesn’t,
> then Lua spits the dummy and tells me I’m indexing a nil value. This
> is technically correct, but actually, I don’t care.
This is my biggest problem with Lua, makes working with optional tables
a real pain and all the solutions have problems; debug.setmetatable is
overkill (I think most people only want this on some table accesses, not
all), and the others are clunky at best.
It was proposed a while back adding an extra operator for safe indexing,
something like a?b?c?d I forget the conclusion of that debate, but would
like to petition for something along those lines.
Scott