Parsing varargs to a function

Sean Conner <[email protected]> Mon, 27 Apr 2026 16:31:12 -0400
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
  I know that to parse varargs, one uses select():

	function f(...)
	  for i = 1 , select('#',...) do
	    local x = select(i,...)
	    print(x)
	  end
	end

  What was the thinking behind this?  Why not?

	function f(...)
	  for i = 1 , #... do
	    local x = ...[i]
	    print(x)
	  end
	end

  That is, treat ... as an array and use existing syntax?  I know this will
not work with ipairs(), but it seems to be a net win.  Currently, with an
empty Lua state, there is no way for code to interate through the varargs
without the select() function (or at least, not easily).

  -spc (Just thinking out loud here ... )


  

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/20260427203112.GA31146%40brevard.conman.org.