Crosscut

Daily Thought - 2024-10-14

Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

This thought was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.

< back to list

I'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.

<< previous thoughtnext thought >>

Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email whenever I post a new one.