lua-users home
lua-l archive

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



On Jun 5, 2015, at 3:08 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:

I would like to have an item named, say, 2015.0605. As it stands now,
I will need
to call it "2015.0605", otherwise maybe some implementation of Lua on the
Blackcurrant Tart computer will get confused when it tries to find #t
on my table.

I think that is an unnecessary restriction. A one-word change in the manual
can lift it.

My view of this is simple; a sequence is the Lua equivalent of an array (or as near as it gets to one). Other languages have survived for decades only allowing positive integral indices in arrays, why is it a problem in Lua?

If you have non-integral numeric keys, you don’t have an array; you have a dictionary with arbitrary keys that happen to be numeric. The # operator is pretty meaningless in this case.

If you really have need for a set of data items indexed by integer keys (an array), and an additional set of *different* data items with non-integral keys, imho you are better off keeping these in discrete tables (perhaps inside a top-level table); segregating data by clever tricks with the data domains is always messy in my experience.

—Tim