lua-users home
lua-l archive

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


It was thus said that the Great Dirk Laurie once stated:
> 2018-01-20 23:46 GMT+02:00 Sean Conner <sean@conman.org>:
> > It was thus said that the Great Benoit Germain once stated:
> >> 2018-01-20 10:43 GMT+01:00 Paige DePol <lual@serfnet.org>:
> >>
> >> > Sean Conner <sean@conman.org> wrote:
> >> >
> >> > >  Why not the following?
> >> > >
> >> > >       function foo(...)
> >> > >         for i = 1 , #... do
> >> > >           print("the answer is",...[i])
> >> > >         end
> >> > >       end
> >> >
> >> >
> >> > As you stated, if the vargs are needed in a table simply using "..." in
> >> > a table constructor could also be used.
> >> >
> >> >
> >> IIR I proposed a patch in that spirit that a while back. Maybe list history
> >> can unearth it. Wasn't production ready though, my knowledge of Lua
> >> internals wasn't good enough.
> >
> >   The thread starts here:
> >
> >         http://lua-users.org/lists/lua-l/2011-05/msg00034.html
> >
> >   Interesting discussion.  It appears that PUC took HyperHacker's idea for
> > _ARG.  There are also some issues brought up in
> >
> >         http://lua-users.org/lists/lua-l/2011-05/msg00107.html
> 
> Hpw soon do we forget ...
> 
> $ lua5.1
> Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> > function f(...) print(arg[1],arg[2]) end
> > f(10,'foo')
> 10    foo

  Only if you have LUA_COMPAT_VARARG defined when compiling Lua.

  At first, I was surprised with this behavior as I don't recall seeing it
in the Lua documentation.  And yes, it was only by doing a search for 'arg'
did I find the note in section 7.1 about LUA_COMPAT_VARARG.

  -spc (So yeah, some of us did forget, for we never knew it in the first
	place ... )