Caterpillar

Daily Thought - 2024-07-25

< back to list

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.

<< previous thoughtnext thought >>