[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Unexpected error using tostring
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 7 Mar 2019 08:35:23 +0200
Op Do. 7 Mrt. 2019 om 07:57 het Dirk Laurie <dirk.laurie@gmail.com> geskryf:
>
> Op Do. 7 Mrt. 2019 om 07:49 het Egor Skriptunoff
> <egor.skriptunoff@gmail.com> geskryf:
> > For some strange reason, Lua is not conceptually clear about nil.
Lua is crystal clear abut nil. (Lua 5.4 work1 muddied the waters, but
work2 returned to orthodoxy.)
> > Nil is defined as absence of value.
It is not so defined.
It is defined as a value whose princlipal property is to be different
from every other value. Absence of value is just one application.
First return value when the second is an error object is another.
> > But tuples in Lua are inconsistent with the definition of nil.
Not so. On the contrary, tuples make it obvious that "absence of
value" is not the definition.
> > IMO, any tuple of values should be think of as padded by nils to infinity.
So select('#',...) might as well return math.huge?
> > Neither in Lua, nor in C API a user should be able to distinguish between LUA_TNONE and LUA_TNIL.
In the C API, LUA_TNONE means you have tried to read above the top of
the stack. It is totally necessary to know whether this has happened.
Must I explain why?
Occasionally it does not matter whether you went over the top or read
an acttual nil, and for that purpose the API has lua_isnoneornil. You
are in effect saying there should not be lua_isnil and lua_isnone too.
-- Dirk