lua-users home
lua-l archive

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


> From: Dirk Laurie <dpl@sun.ac.za>

> You want something like Python's 'tuple'.
> 
> <python>
> 
>     s = {}
>     s[(1,1)] = 11
>     s[(2,3)] = 23
>     i=2; j=3; s[(i,j)]=s[(1,1)]
>     print s[(2,3)]   # --> 11
> 
> </python>

Well -- No. Tupels would do, if LUA would have them, for my purposes, but
why reducing things to tupels or arrays?

> Now here's the rub:  Lua doesn't have Python's syntax for tuple values.
> The above code becomes:
> 
> <lua>
> 
>     s = {}
>     s[Table.todata{1,1}] = 11
>     s[Table.todata{2,3}] = 23
>     i=2; j=3; s[Table.todata{i,j}]=s[Table.todata{1,1}]
>     print s[Table.todata{2,3}]   --> 11
> 
> </lua>
> 
> Even a preliminary `local T=Table.todata` is not going to make that
> look beautiful.

I won't care. Point is, that one cannot do this at all in LUA, right now.

> So IMHO nothing short of fully implementing immutable tables as another
> Lua data type will meet your request.  Keep plugging away, immutable
> arrays (i.e. tuples) are already down below in Lua, and the tip of the
> iceberg is showing on the surface as `...` and `select`.  Probably not
> 5.3, if indeed there will ever be a 5.3, but who knows, Lua 6.0 could
> have it.  Only ten more years to wait …

I wouldn't mind helping to implement it, but i do not know, whether this
feature is wanted. It is missing, and the concept of the central and only
composed data type in LUA clearly lacking.

-lars