Daily Note - 2024-07-25
Hey, I'm Hanno! These are my daily notes on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
This note was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.
Implementing if
was more difficult
than I expected. Which probably says more about my
estimation abilities than the difficulty of implementing
if
. But either way, it required more
sophistication from the compiler than it had before.
Previously, the code was pretty flat and linear. Now,
with blocks of code being passed to if
,
there's a lexical hierarchy to it. This required some
changes to the intermediate representation. I knew from
a previous prototype that content-addressed code
fragments would do the job (and are necessary for
interactive programming anyway), so I just implemented
that.
Those blocks of code also needed to be able to refer to bindings from their parent scope, so I implemented lexical scoping and made those blocks full closures. This was probably a bit more than was necessary right now, but I ran with it. We'll need closures anyway, sooner or later, and now we have them.