3 ms·
They are more obvious, but it wouldn't work in Set or as Map keys, which seems to be a design goal here.
by recursive 1y ago
They are more obvious, but it wouldn't work in Set or as Map keys, which seems to be a design goal here.
- sltkr 1y agoAccording to the author that wasn't a design goal: > While looking all this up, I found Justin Fagnani’s article Composite Map Keys in JavaScript with Bitsets, which is mostly unrelated to what I’m doing here In fact, the author specifically wants his records to be mutable, which precludes using them as Set or Map keys (at least at the same time). So immutable bigints seem like sort of the wrong tool for the job: changing any single field requires creating a completely new number (and while in theory a compiler might be able to optimize away the copy, in practice I doubt this happens).
- recursive 1y agoOh yeah. Huh. I guess I read that wrong.
- dullcrisp 1y agoMaybe just implement a hash function and some buckets and return an interned object? You could implement something with the same functionality but have a lot more flexibility if you’re not relying on cramming things into a bigint.