Capital on Nostr: I have finally ran into a unit test that test for behavior that Lua has but Crystal ...
I have finally ran into a unit test that test for behavior that Lua has but Crystal doesn't.
Lua has the concept of weak tables that allow the garbage collector to remove member from a table automatically. Crystal, however, has no such feature.
You can make a type like Hash(T, WeakRef(U)) in Crystal. And this hash-map will not persist the value referenced by WeakRef(U). However, unlike crystal, when a WeakRef(U) is empty, it is not removed from data structures.
Lua has the concept of weak tables that allow the garbage collector to remove member from a table automatically. Crystal, however, has no such feature.
You can make a type like Hash(T, WeakRef(U)) in Crystal. And this hash-map will not persist the value referenced by WeakRef(U). However, unlike crystal, when a WeakRef(U) is empty, it is not removed from data structures.