Oh, I absolutely agree with this. Iāve been wondering about monontonic, non-moving data structures for a while. But Iāve yet to experiment with building one. In my experiments in that direction, I found that perhaps a persistent data structure would work better ā in particular I was experimenting with different versions of persistent that were oriented at short-lived snapshots and a single master copy, trying to reduce the overhead of inserting data and so forth in that scenario.
The advantages of a persistent data structure is that it shares many of the same properties, but it is able to reorganize and reallocate its internal structure freely. Maybe I wasnāt thinking hard enough, but all the ideas I had for monotonic, non-moving hashtables and the like seemed to have poor lookup performance over time. And of course if you have a persistent data-structure, you can wrap it in an Rc (or Arc) and trivially extract and clone it, and then the user gets a nice snapshot.
Of course, if possible, I find IVars even more appealing: that is, leave a hole for the data, create a standard hashmap or set or whatever sequentially, and then plug it in. But Iāve found that in practice most of the maps DO wind up being mutated in later stages, though often itās only during cross-crate inlining. If we moved away from using global maps, this would be much less of an issue.
Yesterday I started, but didnāt have time to get very far with (story of my life these days, it seems like), going through the data structures and trying to document and list up where they are modified from. I want to sketch out in more detail what I am talking about with regard to per-fn data structures, as well as identifying problematic cases in advance.