Weak Tables
- Tables can have entries that are used by multiple other objects
- They can have objects as keys or values
- The objects referencing the table eventually get garbage collected
- How to garbage collect the entry once it is no longer referenced
The __mode metamethod is used to declare that the keys or the values or both are weak
setmetatable(results, {__mode = "k"}) -- make the values weak
setmetatable(results, {__mode = "v"}) -- make the keys weak
setmetatable(results, {__mode = "kv"}) -- make both weak
If the values or keys are weak once all references to them are gone in the code
The garbage collector will not mark them as having references during mark
They will then be collected during cleaning
```