lua-users home
lua-l archive

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


On Sun, Jun 2, 2019 at 12:21 AM Coda Highland <chighland@gmail.com> wrote:
> On Sat, Jun 1, 2019 at 2:13 PM Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>> There's a specific idiom that this kind of optimization would break,
>> which is when one fetches a key or value from a weak table into a local
>> variable purely to ensure it does not get collected during some process.
>> In this case the local variable might never be referenced at all after
>> assigning it.
> This is often called RAII ("resource acquisition is initialization" but the actual practice of it doesn't quite fit that exact description anymore).

That's similar, nut not quite RAII. Very similar to copying a
ref-counted pointer got from externals in a local, quite used trick.

> The solution is to assert that <toclose> variables are always considered live. It is, after all, an explicit declaration that the end of the variable's lifetime is precisely the same as the end of the lexical scope. And this would also be one of the more common reasons to use a <toclose> variable in the first place, so it's a win-win.

mmm, we were discussing garbage collection stuff, 5.3, no that new
fangled <toclose> stuff for 5.4. Anyway, the manual explicitly states
that ACCESSIBLE values are not dead, no gc, so collecting an
accessible-but-not-accessed variable would contradict that.

Francisco Olarte.