lua-users home
lua-l archive

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


>> Well, I was talking about vanilla Lua. Anyway, the above difference is
>> very weird because it doesn't allow to postpone the usage of varargs,
>> for instance, in some coroutine create/resume loop where arguments could
>> be anything generic. Fortunately, I rely on this behavior only within a
>> testing framework which is run under plain Lua.
> 
> Sadly, the same is true of vanilla lua:
> 
>   $ lua -v
>   Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> 
>   $ lua -e 'print(select ("#", unpack{ 1, nil, nil, nil, nil, nil,nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 3 }))'
>   1
> 

Actually, it slightly differs from what I was talking about. Please consider this:

$ lua -e 'function f(...) local t = { ... } ; print(select("#", unpack(t))) end ; f(1, nil, nil, nil, nil, nil,nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 3)'
17

$ luajit-2.0.0-beta5 -e 'function f(...) local t = { ... } ; print(select("#", unpack(t))) end ; f(1, nil, nil, nil, nil, nil,nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 3)'
1

The difference here is that arguments are stored in a table constructed with { ... }.

// Seny