lua-users home
lua-l archive

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

On 30/07/2019 16.42, Soni "They/Them" L. wrote:
since lua doesn't have refcounting and some ppl wanna do basically"*a") I wanna propose io.lines("filename", "*a")()
(or alternatively io.lines("filename", "*a", "*l")) should close the
file as if the iterator ran out.

function readfile( name )
  local <toclose> f, err = name, "r" )
  if not f then  return nil, err  end
  return f:read "*a"

(or something like that) should work, right?

Sometimes it actually makes sense to read '*a' and then seek back and
read(/write) again…

-- nobody