[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Definition of table.insert
- From: Frank Siebenlist <frank.siebenlist@...>
- Date: Tue, 11 Jan 2011 08:04:17 -0800
I'm not sure if its just nomenclature or if we're mixing metaphors, but isn't it possible to define an array such that it doesn't have any holes in it per definition?
In my view, an array is defined by a range of continuous indices from 1 to n. Any index that is not associated with a value (yet) should have a default value of nil (or some other set default). This implicitly excludes any notion of holes in an array.
I believe that is one of the true distinctions between the map and array views of lua-tables. With maps you cannot distinguish between a hole from an unassigned entry in a standard lua-table, but with an array we can as long as we know the dimension of that array, without any ambiguity.
Could you please define your array semantics in more detail?
On Jan 11, 2011, at 1:45 AM, steve donovan wrote:
> On Tue, Jan 11, 2011 at 11:08 AM, Axel Kittenberger <email@example.com> wrote:
>> Or in other words, tables keep to be the basic Lua building block, but
>> Lists is a default construct that builds on tables and makes
>> insert/remove/# operations easy.
> For instance, . Again, you do pay a penalty, but it should be
> impossible to put holes in your array with this class. It would be
> interesting to find the fastest possible implementation that preserves
> the paranoid properties!
> steve d.
>  http://snippets.luacode.org/sputnik.lua?p=snippets/Safe_Array_100