Daily Thought - 2024-09-22
< back to listI've been doing a bit of light reading on other languages. Just snooping through documentation and code samples. That inspired me to make a change to Caterpillar's syntax.
Here's how function literals looked like, as of yesterday:
{
|a 0|
a
|a b|
a b +
}
The parameters of each branch were delimited by |
. This was directly inspired
by Rust (which might have gotten it from Ruby).
As of last night, the same code looks like this:
{
\ a 0 ->
a
\ a b ->
a b +
}
Each branch now starts with a \
, while a ->
introduces the branch body. This
is directly inspired by Roc, but I've also seen it in Elm and Futhark. I
guess it's an ML-family thing.
I never quite liked how the same token was used on both ends of the parameter list. Now the start of that and the start of the body each look unique.