lua-users home
lua-l archive

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


On Thu, Nov 25, 2010 at 19:01, Mark Hamburg <mark@grubmah.com> wrote:
>        `do `[ args `] `=> exprlist `end
>
> But then Lua needs to implement the appropriate semantic changes because this would have different effects from:
>
>        `do `[ args `] `return exprlist `end
But what happens in the second case if you call the inner function
after the outer one has returned?

    foo = {}
    function bar()
        foo.baz = do[] return "Something" end
    end

    bar()
    foo.baz() --> an error should be raised.


    function bar()
        local _R = true

        foo.baz = do[]
            if _R
            then return "Whatever"
            else error()  end
        end

        _R = false
        -- <----------- return goes here.
    end


-- Pierre-Yves