[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Definition of table.insert
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 11 Jan 2011 09:35:16 +0200
On Tue, Jan 11, 2011 at 9:20 AM, Michal Kottman <k0mpjut0r@gmail.com> wrote:
> When t[k] is nil, table 't' doesn't have a value associated to 'k'.
> t[k] = nil removes the value associated to key 'k' from the table 't'.
>
> Is it difficult to understand? Should I not do it?
It's probably only difficult because people have expectations from
other languages which have pure hashes and pure arrays. We try to fit
the world to an existing model. And to say that a Lua table is a
simple combination of these two 'primitives' is an oversimplification.
But these models can be implemented on top of Lua tables, and maybe
newcomers should be encouraged to use them (leading back to the idea
of the 'absolutely minimal' set of Lua libraries) or at least to learn
the rule that putting holes in arrays is a bad idea.
I suspect in fact that implementing a sparse array naively in Lua is
probably not as fast as old-fashioned double-indexing anyway.
steve d.