Daily Note - 2024-06-30
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.
I've mentioned before that Caterpillar could become less restrictive around how functions are defined, as it grows more features that help to notice and prevent mistakes. Then, function arguments could become implicit, which could look like this:
fn increment { 1 + }
We know that +
takes two arguments, and
since we only provide one argument, we know that the
function needs to take another one. But maybe we want to
make that explicit, in some cases. If we combine the
previous syntax with
my idea for assignment expressions, that could look
like this:
fn increment { => x
{ x 1 + }
}
On a conceptual level, I find this elegant. There is no
special syntax for optional function arguments. Every
function declaration would just be
fn <name> <body>
, and you can
combine that with an orthogonal feature, binding
expressions, to specify arguments where that is
desirable.
But the syntax is kind of ugly, with the double parentheses. Maybe I can come up with something better.