Re: How to convert to-be-closed variable to normal one in runtime?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: How to convert to-be-closed variable to normal one in runtime?
- From: Dmitry Meyer <me@...>
- Date: 2020年7月21日 17:13:52 +0300
It's an ad-hoc solution, but how about:
local function log_start_time()
local logfile = assert(io.open("log.txt", "a"))
local _autoclose_logfile <close> = arg[1] ~= "--log-everything"
and logfile
...
It would be more flexible if the <close> attribute doesn't imply the
<const> (it would be possible to just rebind logfile to nil). But I
understand why it was designed that way.