lua-users home
lua-l archive

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




On 2018-07-20 05:00 AM, Javier Guerra Giraldez wrote:
On 19 July 2018 at 21:44, dyngeccetor8 <dyngeccetor8@disroot.org> 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.
you're not dumb.  it's _very_ rare that code in itself, without any
hint of its purpose, can be an effective way of communication.




It's an (attempt at an) "with" block/statement/construct using for loops. If you'd just read the "for x in with(io.open(filename)) do", emphasis on the "with"...

(Code is a language like any other, and can be read like any other. I find this an useful skill to have, as it helps with reverse engineering and tracking down bugs, and it also helps with reading my and other ppl's posts.)