lua-users home
lua-l archive

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


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
>
$ lua5.2
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> function f(...) print(arg[1],arg[2]) end
> f(10,'foo')
stdin:1: attempt to index global 'arg' (a nil value)
stack traceback:
    stdin:1: in function 'f'
    stdin:1: in main chunk
    [C]: in ?