lua-users home
lua-l archive

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


>> What's the more "Lua" way to generically create a closure for a given
>> function and its arbitrary arg list than the following:
> [snip<]
>
> How about something like:
>
> function closure(func, ...)
>     return function() call(func, arg) end
> end
>
> for Lua 4

Boy, I'm really at it: I forgot the upvalues as well as the return. Then
again, it's way past midnight here in the lowlands. So people should
probably bear with me... [;-)]

Anyways, my proposal for Lua 4 should have read:

function closure(func, ...)
    return function() return call(%func, %arg) end
end

Ashwin.