lua-users home
lua-l archive

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


On Wednesday 23 June 2004 01:46, O'Riain, Colm wrote:
> Thanks to Jamie and Virgil for your quick answers. I had tried closures
> before but when I use closures, nothing happens when I call that 3rd
> parameter:

That's because your example doesn't actually call the function. To be clear:
Suppose you have a function f, defined as follows:

function f()
    return 1
end

Try the following two lines of code:

print(f)
print(f())

The first line will print 'function: 0xXXXXXX', and the second line will print 
'1'. You need to use the brackets to indicate that you are actually calling 
the function as opposed to just referring to it.

Specifically, you need to use the syntax convtable[1][3]() to actually call 
the function.

-- Jamie Webb