lua-users home
lua-l archive

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



On Dec 17, 2013, at 2:08 AM, Sir Pogsalot <sir.pogsalot@gmail.com> wrote:

You probably already know this, but weak tables only work for garbage collected reference types with explicit constructions[1], e.g. tables and userdata, but not numbers, booleans, strings, and light C functions.

I didn't actually know that :o  I think it's just something I never consciously thought about until you mentioned it... how do those others get collected?  I guess what I wrote still stands for userdata at least?  Where do threads/coroutines stand in that?

Only “by reference” types are collected, which includes tables, full userdata and threads. In fact, it’s the fact that these items are multi-reference that makes them subject to GC semantics. Things like booleans, numbers etc are not collected because there lifetimes are explicit. Strings are a special case because, although they are by-reference, they are interned which means they act like values.

—Tim