lua-users home
lua-l archive

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


On Mon, Jan 14, 2002 at 01:05:01PM -0500, RLake@oxfam.org.uk wrote:
> This solves pretty well all the problems presented. If you want to stuff a
> value into a table, even if it might be nil, you say:
> 
> John.isMarried = !a
> 
> To get it back out again, recovering it's original truth value (or
> returning nil if the key didn't exist), you say:
> 
> a = ?John.isMarried
>
> To check if you know about John's marital status, you say
> 
> if John.isMarried then ...
> 
> to check what it is, assuming that unknown is tantamount to single, you say
> 
> if ?John.isMarried then ...

This is gross. Why should we litter all our code with obtuse "?!?!!"
puntcuation?

With booleans, I can just do:

John.isMarried = false
if John.isMarried then
  print_past_wedding_information();
else
  plan_wedding();
end

> This also solves the ternary (a and b or c) issue:
> 
>     a and !b or c

To 90% of the programmers of the world, this reads "a and not b or c".



-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net