Daily Thought - 2024-10-15
< back to listLet's switch gears and think about maps for a second. It's totally reasonable to store your data in one of those, and just refer to it indirectly, via some kind of handle that is associated with a value in the map. It's also reasonable to expand on that. Create a special map that generates a handle for you when you insert something.
Maybe such a special map could even implement a strategy for managing handles and values. Like making handles unique, and requiring you to return the unique handle to the map when you're done with a value. Or keeping track of which handles exist, and when the last one for a value is dropped, remove that value from the map.
Suddenly, those special maps start to sound like heaps, plus a strategy for managing the memory there. But neither of those would be built into the language. They could very well be implemented in a third-party library. So maybe Caterpillar will have references after all. They might just come in the form of handles into various maps.