lua-users home
lua-l archive

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

On 09/07/15 10:16 PM, Daurnimator wrote:
On 10 July 2015 at 10:50, Egor Skriptunoff <> wrote:
On Fri, Jul 10, 2015 at 2:38 AM, Coda Highland <> wrote:
On Thu, Jul 9, 2015 at 4:30 PM, slayer beast <>
I would love to have a syntax like this:

some_table['a_name', 'another'] = a, b
Sadly this conflicts with one of the suggestions for the tuple-keyed
table proposal. We can't have them both.

This is tuple-keyed assignment:
some_table['a_name', 'another'] = c

And this is two distinct assignments:
some_table[ ('a_name', 'another') ] = a, b

Old good idea: parentheses mean converting a tuple to a single value.

Neither translate well to the __newindex metamethod.
__newindex = function(t, k, ...)
Is the ... extra keys follows by a value, or multiple values

I'd prefer that we limited it to a single value.
This way it isn't ambiguous; but it's still awkward (optional middle
arguments... ew!)

Syntax sugar.

t[k1, k2, k3] = v1, v2, v3 -->
mt.__newindex(t, k1, v1)
mt.__newindex(t, k2, v2)
mt.__newindex(t, k3, v3)

Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.