lua-users home
lua-l archive

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


Mixing strings and offsets is something javascript for example can do
as well. Lua has full associates tables tough. Mixing lists with
string indixes doesn't hurt the iist or # in anyway. Mixing the notion
of an integer keyed hastable with a linear list does.

On Tue, Jan 4, 2011 at 10:47 PM, Gavin Wraith <gavin@wra1th.plus.com> wrote:
> Apologies if I am dragging a red herring across the path of the
> hounds, here. I cannot help noticing a flurry of recent activity
> on the subject of holes in tables, the definition of # etc.
>
> I note that other programming languages make a distinction between
> "lists" (indices a consecutive sequence of integers starting at 1 or
> 0 or whatever) and "hash tables", usually with strings as indices.
> That Lua amalgamates and extends the two seems to me to be one of
> its most interesting aspects. So how do others exploit this
> amalgamation in their Lua programming?
>
> For myself, I often have lists and then find it useful to add methods
> to them - something that would not be so convenient if lists and hash
> tables were separate notions. I tend to use the list simply as a stack,
> with non-nil entries, so the hole problem never arises. But maybe I am
> overlooking other useful ways of exploiting the amalgamation?
>
> In any case it seems to me that it would be good PR for Lua if
> in example code snippets those idioms which are currently unique to Lua
> were to be highlighted.
>
> --
> Gavin Wraith (gavin@wra1th.plus.com)
> Home page: http://www.wra1th.plus.com/
>
>