lua-users home
lua-l archive

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




On 2018-07-19 05:44 PM, dyngeccetor8 wrote:
On 07/19/2018 04:14 AM, Soni "They/Them" L. wrote:
local with = require "with"

local f = with ^ function(with, do_error)
   for x in with({close = function() print(4) end}) do
     for y in with({close = function() print(2) end}) do
       print(1)
     end
     print(3)
   end
   print(5)
end
---

and prints 1, 2, 3, 4, 5 in that order
Reading your messages leaves me a feeling that I'm dumb and this is
something outstanding, or that this is some complex way to print
1, 2, 3, 4, 5.

-- Martin


If they were files, instead of tables with a close function, they'd be actually closed in the correct order.

Oh, I just realized having a "return" or "break" inside the block/for loop would cause issues... Hmm... Oh well, at least I tried I guess :/