lua-users home
lua-l archive

nil isn't as unique in Lua 4.1

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


I'd rather not have the boolean type because then there will be a need
for functions like Perl's 'defined' (to tell if a variable is not nil)
and 'exists' (to tell if a table has a value for a particular key). How
else with you be able to tell if a variable is false or nil?
In Lua 4.0, it is simple to delegate to another table:
 x = t1[i] or t2[i]
If element i isn't in table t1, try t2. But in 4.1, if t1[i] is false,
then this expression will access t2 when you don't really want it to. I
don't want to see Lua start looking like this:
 $x = exists $t1{$i} ? $t1{$i} : $t2{$i} ;
- Peter

AltStyle によって変換されたページ (->オリジナル) /