[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Accessing Table's table value from C++
- From: Javier Guerra <javier@...>
- Date: Sat, 5 Feb 2005 09:51:18 -0500
On Saturday 05 February 2005 9:12 am, Ashwin Hirschi wrote:
> Of course, having a little error-checking in there wouldn't hurt [unless
> you're absolutely sure all your data is always available]. For instance, if
> the 2nd table would somehow be missing, Lua would (quite correctly) throw
> an alert during your last lua_gettable call. Depending on circumstances,
> that could be a bit embarrassing, I think.
that's one thing i think could be different. in this case, the C calling code
should do all the error-checking, no argue with that. but in Lua, i find
lots of times i want to do something like this:
var = table[index].field
but if i'm not sure that [index] is present in that table, i have to split in
two:
local temp = table[index]
if temp then var=temp.field else var=nil end
usually, i don't care about intermediate values, just if any part of the table
fetchs fails, the whole expression should be nil, and i'd be happy to check
the result just once and not every step.
in short, i'd like that
(nil)[anything] == nil
instead of failing
does anybody object to this?
--
Javier
Attachment:
pgpobtjlEj8dv.pgp
Description: PGP signature