lua-users home
lua-l archive

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



On 09/04/2014 17:13, Coroutines wrote:
>From what I remember, extending the 'in' keyword was originaly
propositioned in this form only:

local a, b, c in some_table

I consider it an advance to make it more general for expanding a
vararg from a table without an intermediate table:

The expression: a, b, c in some_table    -- which can appear in any expression

Making this syntactic sugar:

local a, b, c in some_table -- parsed as: local a, b, c = a, b, c in
some_table  becomes: local a, b, c = some_table.a, some_table.b,
some_table.c

While still allowing people the potential to prefix local imports:

local pre_a, pre_b, pre_c = a, b, c in some_table

A new question:  Should only valid identifiers be used before the
'in'? Or do we allow identifiers and objects?

local t = {}
some_table[t] = 'cat'

local a = t in some_table

(Do we index from some_table by identfier name or by what it
potentially references?)

I vote by identfier names only, I would see the 2nd as being somewhat confusing.

I vote for this:

local t = {}
some_table[t] = 'cat'

local a = [t] in some_table