lua-users home
lua-l archive

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


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