lua-users home
lua-l archive

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


On Mon, Nov 17, 2008 at 9:53 AM, Evan DeMond <evan.demond@gmail.com> wrote:
> You can always use do...end blocks to scope things the way you like it.

yep, but it's not really nice.  imagine something like this:

unwinder(function ()
    local fileone = open(.....)
    yield (function() fileone.close() end)
    .... do some stuff...
    local otherresource = acquire(....)
    yield (function() otherresource.release() end)
    ... still some more...
    .... just finish
    return whatever
end)

and the unwinder() would store the yield()'ed releaser functions in a
LIFO, and call them all when the main function finishes, be it
normally or with an error.



-- 
Javier