lua-users home
lua-l archive

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

Diego Nehab wrote:


While we are at it, anyone thought about having ... as an "l-value"?

    function capture(s, pat)
        local i, j, ... = string.find(s, pat)
        return ...

I would love this. Too many times I have to choose between
local ret,err,a,b,c,d = fn()
if not ret then f2(a,b,c,d) end

local t = {fn()}
if not t[1] then f2(unpack(t,3,table.maxn(t))) end

neither is pretty.

But how do we distinguish between the "vararg" "..." and the l-value "..." ?
Only ever allow one list, I think, so l-value overwrites previous "..."