lua-users home
lua-l archive

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


2015-07-04 16:55 GMT+02:00 Cosmin Apreutesei <cosmin.apreutesei@gmail.com>:

> [Shouldn't Lua have built-in tuples by now? :) Tuples are very useful in
> application code, but hardly ever present in library code so I can see how
> they could be undervalued by low-level coders. As I move between being a lib
> coder and an app coder I sometimes wonder/worry about these differences in
> perspective and how they affect the APIs that we create for app usage. I
> admit that I don't always drive API design from real use cases myself but I
> try goddamn it.]

Tuples are a special case of constant values. E.g.

const c = {1,2,3}

would create a constant table with three elements and associate it
with the name c. The interpreter will remember that _ENV.c for this
_ENV may not be redefined. A constant value can only be assigned
to such constant table fields.

One would probably has to disallow tables with a hash part from
being declared constant. I.e tuples == constant sequences.