lua-users home
lua-l archive

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


Is this wishing to much as to being able to say something to the tune of 

function f(...)
	for k in (...) do
		print ((...)[k])
	end
end

I thought I'd ask as it seems to make sense to treat ... with more utility:)

>-----Original Message-----
>From: Roberto Ierusalimschy [mailto:roberto@inf.puc-rio.br]
>Sent: Friday, September 03, 2004 11:06 AM
>To: Lua list
>Subject: Re: Lua 5.1w crash bug -- '...' related 
>
>
>> BTW: I had hoped that:
>> 
>> function foo(...)  print(unpack(arg), '\n') end
>> function foo(...)  print(..., '\n') end
>> 
>> Would behave differently, with the former printing only the 
>first arg,
>> and the latter printing all arguments as if the arguments had
>> literally been expanded inline. That's not how it works, huh?
>
>No. The `...' is equivalent to a function that returns multiple
>arguments.  `...' and unpack(arg) are completely interchangeable.
>
>-- Roberto
>
>