[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Nil and false in Lua design
- From: "Joseph Manning" <manning@...>
- Date: Tue, 15 Oct 2013 09:05:53 +0100
On 2013-Oct-15 (Tue) at 05:38 (+0000), Thomas Jericke wrote:
>> There are less theoretical situations where the current
>> implementation is unintuitive. Mostly the 'or' and 'and' operators.
>> They do not only accept non boolean values, they also return
>> non-boolean values. typeof(A or B) could be anything, and 'A' and
>> 'B' don't even have to change their types for "A or B" to change
>> its type.
>>
>> typeof(true or 10) -- boolean
>> typeof(false or 10) -- number
Thomas,
I suggest that 'and' and 'or' in Lua may feel unintuitive only if
you expect them to just be the traditional boolean operators.
But they are much more general than that, while of course including
the standard behaviour as a particular case.
This generality may feel weird at first, but once it becomes familiar
it can be very convenient indeed.
Joseph
------------------------------------------------------------------------
Joseph Manning / Computer Science / UCC Cork Ireland / manning@cs.ucc.ie
------------------------------------------------------------------------
- References:
- Re: Nil and false in Lua design, Thomas Jericke
- Re: Nil and false in Lua design, steve donovan
- Re: Nil and false in Lua design, Dirk Laurie
- Re: Nil and false in Lua design, Carsten Fuchs
- Re: Nil and false in Lua design, Thomas Jericke
- Re: Nil and false in Lua design, steve donovan
- Re: Nil and false in Lua design, Carsten Fuchs
- Re: Nil and false in Lua design, steve donovan
- Re: Nil and false in Lua design, Sean Conner
- Re: Nil and false in Lua design, Thomas Jericke