lua-users home
lua-l archive

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


What's wrong with Joonas Pihlaja's proposal?

 do with f, g = io.open("src.txt","r"), io.open("dst.txt",w")
    for l in f:lines() do
       ...
       g:write(l)
    end
 end

(Probably with a different syntax...)


I've been using it in metalua for a while (syntax "with <var_list> = <values_list> do <scoped_statements> end") for some time, with the convention that the protected variables must have a ":close()" disposal method, and I'm pretty happy with it.