lua-users home
lua-l archive

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]


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.

AltStyle によって変換されたページ (->オリジナル) /