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.
Published at
2023-07-01 21:39:34Event JSON
{
"id": "e363cc6c2331cf5c0f0c474bb5c9092cc1ebc2dcbe2a4508e29a97b386ae7b51",
"pubkey": "19132ebf4163a2399191bc90c23f33d1fe4945cbe9c807b0d196b172a2701961",
"created_at": 1688247574,
"kind": 1,
"tags": [
[
"mostr",
"https://furry.engineer/users/CapitalEx/statuses/110640993018868855"
]
],
"content": "I have finally ran into a unit test that test for behavior that Lua has but Crystal doesn't. \n\nLua has the concept of weak tables that allow the garbage collector to remove member from a table automatically. Crystal, however, has no such feature. \n\nYou 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.",
"sig": "99708a882924b60f6d422e37e0101438f4ee2fc1d12062b6949f3e26e2b6e83a69a850381cc327da6e44db0f39d580ec74432df5c3f17b5844ad75016739f801"
}