Daily Thought - 2024-10-14
< back to listI've mentioned my plan a few times, to not have references in Caterpillar. If data is immutable, then semantically a reference is the same as a copy. The compiler can optimize this, replacing copies with references under the hood, where appropriate. With pre-compiled code in a database, the result of that optimization can even be displayed explicitly.
That whole plan was very tentative in the first place, and I've just discovered a new complication: What about recursive data structures? If a type refers to itself, either directly or through a series of other types, you need a reference in there somewhere. Having infinitely-sized types won't work!
And while I can easily imagine the optimization I've described above, especially in the presence of a linear type system, I'm not sure that something similar is feasible for recursive data structures. I mean, maybe it is, but wouldn't the correct optimization depend on how the type is used, not how it's structured? That could get tricky.