[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: NaN (was: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage))
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 25 Jul 2016 13:02:38 +0200
On Mon, Jul 25, 2016 at 12:36 PM, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
> The "holes problem" exists only in the context of sequences,
> so introducing "null" type is not a good idea as it affects the whole
> language.
It would not be a type - it would be equivalent to you having declared
'null = {}'. It becomes a convention that module writers can depend
on.
> local tbl, idx_from, idx_to = table.pack(...)
Hm, then why not `local tbl, n = table.pack(...)?
When I see awkwardness, I tend to wrap over it. Tuples have been on my
mind recently. In Penlight (soon for new release) I simply extended an
existing tuple type, which was used as a testing convenience:
https://github.com/stevedonovan/Penlight/blob/master/lua/pl/test.lua#L112
That is, override __len and let it know about table.unpack.
Then:
local T = require 'pl.test'.tuple
function foo(...)
local args = T(...)
for i = 1,#args do
...
end
--- forwarding
boo(args:unpack())
end
Not suggesting this as any kind of canonical solution, but it hides
that .n which annoys people so much.
- 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
- NaN (was: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage)), Soni L.
- Re: NaN (was: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage)), steve donovan
- Re: NaN (was: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage)), Dirk Laurie
- Re: NaN (was: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage)), steve donovan
- Re: NaN (was: Re: The Undefined Country (was Re: Quest: real world "Lua array with holes" usage)), Egor Skriptunoff