1 Jun 01:01
Re: Re[2]: state of the Lua nation on resource cleanup
Mark Hamburg <mark <at> grubmah.com>
2009-05-31 23:01:00 GMT
2009-05-31 23:01:00 GMT
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
RSS Feed