Daily Thought - 2024-06-28
< back to listWhen you create new bindings in Caterpillar (or "variables", as they are often called in other languages), you modify the current scope. I'm intrigued by the thought of not allowing that, and instead creating a new scope every time you create a binding. (This is how functional languages tend to do it.)
Here's an idea for how that could look:
a b + => x
{ x x * }
We have an expression, a b +
, we bind the result of that expression to the
name x
, and then we can use that x
in a new scope that the binding operation
creates (the code between {}
).
If there was much more code within that block, we wouldn't need to read all of
it to understand the x x *
expression, because none of that other code could
change what x
is. I have little practical experience with languages that work
like that, but it seems like this could contribute to making code easier to
understand.