[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 26 Jul 2016 11:45:52 +0200
2016-07-26 10:57 GMT+02:00 Thomas Jericke <tjericke@indel.ch>:
> Am 26.07.2016 10:47, schrieb Dirk Laurie:
>>
>> 2016-07-26 8:55 GMT+02:00 Thomas Jericke <tjericke@indel.ch>:
>>
>>> As interesting statements like (a = a or 5) are there is
>>> one thing you always have to remember while programming Lua, testing for
>>> existence and testing for truth is the same unless you use explicit
>>> comparison.
>>
>> Actually, no. 'false' exists but does not test true. In fact, the type
>> 'boolean'
>> was introduced in Lua starting at Lua 2.1 precisely because a value with
>> that property was needed.
>>
> I think you didn't understand me, probably because I wasn't clear enough.
>
> If you use an if statement or use any boolean expression other than == you
> don't know whether you are testing for the value true of a boolean or for
> the existence of any value as you don't (always) know in beforehand if the
> type of that expression is boolean or not at programming time.
>
> Usually it doesn't matter as you know what kind of value you are dealing
> with, it is only a problem if you write some code that handles booleans and
> other types.
OK, actually we seem to agree.
I have on occasion exploited the trichotomy nil/false/everything else,
but commented it very carefully indeed. E.g.
-- 'dvi' is the command for processing a DVI file, but there are two
-- reasons for not needing it and it is important for the automatic
-- selection of a TeX engine to know which is in effect. This is
-- possible by exploiting the the fact that Lua has two false values.
-- dvi == nil "do not produce a DVI file" (but maybe PDF)
-- dvi == false "do not process the DVI file" (but stop after TeX)
- References:
- Quest: real world "Lua array with holes" usage, Rodrigo Azevedo
- Re: Quest: real world "Lua array with holes" usage, Roberto Ierusalimschy
- Re: Quest: real world "Lua array with holes" usage, Jorge
- Re: Quest: real world "Lua array with holes" usage, Hisham
- Re: Quest: real world "Lua array with holes" usage, Roberto Ierusalimschy
- The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Sean Conner
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), nobody
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Jonathan Goble
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Doug Currie
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), steve donovan
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Philipp Janda
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Thomas Jericke
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Dirk Laurie
- Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage), Thomas Jericke