lua-users home
lua-l archive

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


Dirk,
> > for k in pairs(tbl, 'k') do
> > for v in pairs(tbl, 'v') do
> > for k, v in pairs(tbl, 'kv') do  -- the default value of second argument
>
> Neat, especially the second one

Though it doesn't lend itself to similarly efficient implementation and can't really provide real performance benefits; for _,v in pairs() is just fine.

> — but the idiom 'for _,v in pairs(tbl)
> do' is so well entrenched .

And undeservedly so.

> IIUC, the OP's "conservative" proposal is merely that 'pairs' should
> not discard extra arguments, i.e. it should trigger __pairs(tbl,...)
> rather than just _pairs(tbl).

Note I never wrote about changing meaning of any existing Lua core functions. Reread original email if that's not obvious.

> Why change 'pairs' in standard Lua if this is so easy?

See above.

Best regards,

--
DoubleF