lua-users home
lua-l archive

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


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

Well, I knew I would run into opposition :-)

The point is that 99.9% of the time you wouldn't need to. It would just
work logically. The only time you would need to worry about it is when you
were trying to put nil into a table. You can't currently put nil into a
table, and that (as I understand it) is what all the fuss is about.

However, in the final analysis, there really are three distinct truth
values (or more); you cannot use boolean operators to distinguish three
ways (by definition). How, then, does one write "a exists" "a is true" "a
is false" "a is undefined" "a is unknown" etc.?

One can use English, and I could have proposed English words, but I was
trying to make it easy.


> > 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".

With all due respect, speaking for 90% of the programmers in the world is a
bit of a challenge. I accept that for you that's how it reads. Think of a
better symbol, then. I was just using ! and ? as examples, and I did point
out that C/Perl programmers might have a problem with that.

PS:

Q: Why does one use !!foo in C++ ??

A: Because it gives you a true boolean. foo could have been any type with a
Boolean conversion. There is no rule that says, for example, that the
"false" or "null" pointer is represented by a bitstring consisting entirely
of 0s. However !!foo is either 0 or 1. I would say that this is amongst the
reasons I program in C when forced to, not for pleasure, but perhaps 90% of
the programmers in the world it's normal.

R.