lua-users home
lua-l archive

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

On 2 Mar 2011, at 05:43, steve donovan wrote:
However, a simple C extension P could be written that could make 'for
i,v in P(...) do' pretty optimal - it's very efficient to access
multiple arguments in C.

I don't know about how optimal it is, but anyone interested can take a look at library 'vararg' ( #vararg) that allows you to do:

require "vararg"
for i, v in vararg.pack(...) do
	print(i, v)

It creates an new closure for each call of 'vararg.pack' and the number of elements in the '...' cannot exceed 254 elements.

Renato Maia
Computer Scientist