lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2/15/11, Matthew Frazier <leafstormrush@gmail.com> wrote:
> (...)
> Anyway, a more detailed version of my idea would be:
>
> - Tables keep track of which fields are assigned to, and can actually
> store nil.
> - An index operation on a table where the key does not exist returns no
> value.
> - Two additional operations on tables are provided - a "contains"
> operation (i.e. t has key) that tells whether the table has the key set
> as a value, and a "delete" operation (i.e. delete t[key]) that removes
> the field completely.
> - If you attempt to compare, do math with, concatenate, use in a
> boolean, bind to a local, pass as an argument to a function (besides the
> last one) or store in a table a value that isn't actually there (i.e.
> t[key] for a non-existent key, or ... when no varargs were passed), nil
> is substituted for it.
> - The array length operator is modified to count up to the highest field
> that is *defined*, not the highest field that is not nil. (This allows
> tables to contain nils.)
> - Iterators cancel not when the iterator function returns nil, but when
> it returns no values whatsoever. (This allows iterators to return nils.)
>
> So yes, I am part of the "Make nil a first class value" crowd. (I also
> think varargs should be a first-class value, but that's another thread.)
> Having nil as a first-class value is more consistent and interoperable
> than having it as a first-and-a-half-class value.
> --
> Regards, Matthew Frazier
>

May I suggest the definition of a Map type, implemented in pure lua,
on tables, implementing whatever interface the first one to submit it
Luarocks may choose? (maybe one could even write a tree implementation
as well)

I'd do it here, but the margin, you see... it is too narrow :)