[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re[2]: state of the Lua nation on resource cleanup
- From: Mark Hamburg <mark@...>
- Date: Sun, 31 May 2009 16:01:00 -0700
Or look to C# and call it "using":
using query = DB.execute "select * from blah" do
for row in query do
-- do something with row
-- return statements work as intended and error location is preserved
end
end
[ Side note: This requires having query support a __call metamethod
and a close method. Since we're probably going to call it a lot more
than we're going to close it, it serves as an argument for the
function specific metatables. ]
Now, what that probably then really argues for is a way to guarantee
finalization in for loops so that one could write:
for row in DB.execute "select * from blah" do
-- do something with row
-- return statements work as intended and error location is
preserved
end
That, however, without using would lead to a tendency to construct
iterate once constructs to get finalization.
Mark
- References:
- Re: state of the Lua nation on resource cleanup, Cosmin Apreutesei
- Re: state of the Lua nation on resource cleanup, David Manura
- Re: state of the Lua nation on resource cleanup, Cosmin Apreutesei
- Re[2]: state of the Lua nation on resource cleanup, Bulat Ziganshin
- Re: Re[2]: state of the Lua nation on resource cleanup, David Manura
- Re: Re[2]: state of the Lua nation on resource cleanup, Cosmin Apreutesei
- Re: Re[2]: state of the Lua nation on resource cleanup, Matthew Wild
- Re: Re[2]: state of the Lua nation on resource cleanup, Cosmin Apreutesei
- Re: Re[2]: state of the Lua nation on resource cleanup, Peter Cawley
- Re: Re[2]: state of the Lua nation on resource cleanup, Cosmin Apreutesei
- Re: Re[2]: state of the Lua nation on resource cleanup, Peter Cawley