lua-users home
lua-l archive

Any thoughts on indexing ...?

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


Hey all,
Just wondered if the following syntax is being considered at all:
for i = 1, #... do
print(...[i])
end
Imo it seems a natural extension, and less cumbersome then:
local select = select
for i = 1, select("#", ...) do
print(select(i, ...))
end
And would of course be orders of magnitude faster for large varargs.
It would also allow writing select in pure lua, something which is currently impossible.
Still, I can see that some people may not like the syntax, just wanted to throw it out
there anyway.
- Alex
P.S. I do realise it's a little inconsistent, as true lists will never be indexable... eg:
local a = (1, 2, 3)[3]

AltStyle によって変換されたページ (->オリジナル) /