Caterpillar

Daily Thought - 2024-08-16

< back to list

I think pattern-matching functions (and all functions in Caterpillar are pattern-matching, strictly speaking; I'm just being explicit) have the potential to be the basic primitive that all other conditionals are based on. Since recursion is already the only form of iteration, that would make functions the only control flow primitive.

I'm currently in the process of removing all other conditionals from the language, to see what pattern-matching functions feel like in practice. But I expect to add back other flow constructs, like if or pattern matching expressions, over time. But then purely as syntax sugar for pattern-matching functions.

I think having only one concept, pattern-matching functions, as the foundation of all control flow, is elegant, makes for a simpler implementation, and is hopefully easy to comprehend. You only really have to understand one concept. And if you see an unfamiliar control flow construct, you just have to look up how it maps to that one concept you already know.

<< previous thoughtnext thought >>