4

This as the most simple example as I can imagine:

function NewPrint(...)
    print("printed:", ...)
end

NewPrint("Hi")

Please note, I haven't actually done Lua for a while, I might have missed some syntax.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Frederik Spang
  • 3,379
  • 1
  • 25
  • 43
  • The old `arg` table is equivalent to `{...}`. And `local a, b = arg[1], arg[2]` would be equivalent to `local a, b = ...`. – Tom Blodget Jun 18 '13 at 20:08

2 Answers2

5

As per the Lua.org documentation , it was Lua 5.1 .

Lua 5.1 was released on 21 Feb 2006. Its main new features were a new module system, incremental garbage collection, new mechanism for varargs, new syntax for long strings and comments, mod and length operators, metatables for all types, new configuration scheme via luaconf.h, and a fully reentrant parser.

AllTooSir
  • 48,828
  • 16
  • 130
  • 164
2

The syntax in function definition has been introduced in Lua 5.0 (manual) Lua 2.5 (thanks to Luiz for correcting me), but it required to use arg table when you wanted to access those varargs. This has been fixed in Lua 5.1, which allowed to use ... notation for definitions and access to varargs.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • vararg functions were introduced in Lua 2.5: see http://www.lua.org/versions.html#2.5 and the table in page 6 of the HOPL paper, http://www.lua.org/doc/hopl.pdf . – lhf Jun 18 '13 at 21:08
  • @lhf; thank you for the clarification! I didn't go that far and don't have experience with versions older than 5.0 ;). – Paul Kulchenko Jun 18 '13 at 21:13