lua-users home
lua-l archive

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


On Thu, Apr 10, 2014 at 11:51 AM, Andrew Starks <andrew.starks@trms.com> wrote:
> local a, b, c = t[1]
>
> ...becoming a common idiom is reason enough for me.

But this is very ambiguous; my Lua brain immediately assigns t[1] to
a, and leaves b and c unassigned.  Ah, but you say:  t has a special
metamethod!  But I say, I can't tell from the static code context,
which is where human readers operate.

To me, we are looking for new idioms that everyone can agree are clear
and useful, like 'local x,y,z in t'.  (although 'everyone' is probably
impossible on lua-l) They are greeted by a sigh of relief, and some
tedious boilerplating is no longer needed.

But the multiple-arg [] operator returning multiple-values - I don't
get the excitement. Or the need for __index to return multiple values
- that doesn't make sense, because semantically __index must mimic the
indexing of a table.  Otherwise - suddenly "special" values are
running wild in my code.

We need more than one liners here for these proposals to start looking
interesting,