lua-users home
lua-l archive

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


Just in case you need to iterate the ... then you can of course do

function foo( ... )
    for k,v in pairs{...} do
        print( k,v )
    end    
end
foo( "some", true, 1 )








On 4 October 2013 12:49, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2013/10/4 Tysen Moore <tsmoore248@gmail.com>:

> I have a question regarding the usage of the ellipsis ("...").  I am seeing
> some sort of conflict with the hidden "arg" variable and the ellipsis.  If I
> mix usage in a function I get bad results--arg goes nil.  I have
> successfully used this operator in the past but somehow avoided this
> particular use case.

The hidden "arg" variable is a Lua 5.0 feature. It is only part of Lua 5.1
if LUA_COMPAT_VARARG is set in luaconf.h. Lua 5.1.x ships with
all compatibility options on by default, which makes one feel that the
hidden "arg" is part of Lua 5.1, but actually all that is promised is that
if you use it exactly as in Lua 5.0, you will not have problems. If you
use ellipsis in the same module, it's no longer exactly as in Lua 5.0.




--
Jane.

Jane Taubman | www.rjt.org.uk | www.taubman.org.uk |www.fhug.org.uk