lua-users home
lua-l archive

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

I have need to create a weak set of strings -- i.e., I want to create a set
of strings where I can check to see whether a string is in the set but I
don't want to keep the string alive if the only reference is from the set.

For all garbage collected objects other than strings, a fully-weak table
using keys to hold the set elements and true as the value would do the job

Strings, however, don't seem to work this way presumably out of concern that
strings can be recreated later and would still need to map to the same
value. Is that concern, however, really worth making strings behave
differently with regard to weak tables? This would presumably also make a
cache mapping file names to file contents fail to function correctly if both
sides were represented as strings.