lua-users home
lua-l archive

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



On 14/04/2014 13:54, John Hind wrote:
Date: Mon, 14 Apr 2014 08:46:54 -0700
Subject: Re: Lua 5.3 Proposal: Bring back pack()/unpack() for storing
Wouldn't that be like...
n = select('#',...)
v = (select(2,...))

Yes, that would be the current way you do that.  I think he's saying
he wishes for sugar. :-)
Not at all! Implemented properly, this should be much more efficient,
particularly if there are a lot of varargs and you are processing them all
in a loop with repeated select(n, ...). Also it should be more efficient
than the other common idiom of using the vararg operator in a table
constructor.



local n,v1,v2,v3,v4,v5,v6,v7,v8,[repeat],vn = select('#',...),...; etc?
Hmm actually now I see how #... and ...[x] would be useful... otherwise you have to use debug.* which's not portable... (also I wonder, can you do select(...) with debug, and is it faster?)