lua-users home
lua-l archive

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


2014-04-09 6:30 GMT+02:00 Coroutines <coroutines@gmail.com>:

> I think I would suggest both an 'in' and 'from' so this would be possible:
>
> local a, b, c in some_table
> local t_concat, t_insert = concat, insert from table

The proposed 'in' is attractive to those whose programming style
involves locals with the same name as globals (in _ENV) and
nothing like it can be done in Lua without duplicating the names.
Though this is a mere sugar, I would probably use it if available.
The fact that it does not require another keyword also counts
in its favour.

The proposed 'from', on the other hand, is not too hard to imitate
in pure Lua.

    local t_concat, t_insert = from(table,"concat,insert")

I don't think the impact is dramatic enough to justify another keyword.

> I'm thinking about making it of the form:  table.import(into, from,
> options{}, ...)

There is something not too dissimilar in Penlight — maybe Steve can
chip in here.