Caterpillar

Daily Thought - 2024-05-05

< back to list

I've been talking about why Caterpillar uses postfix operators. Yesterday, I introduced how those work for simple math operations, comparing them to infix. Today, I'd like to conclude the comparison to infix, by explaining why infix operators aren't an option as the only kind of operator in Caterpillar.

So, why is that? For a start, because they only work with two operands. If you have fewer, you need prefix or postfix anyway. If you have more, you need to repeat the operator (1 + 2 + 3). Postfix operators have a similar problem (1 2 + 3 +), but also an easy way out. If you use arrays, you can write something like [ 1 2 3 ] + instead.

Infix operators have the advantage of being familiar. But in addition to not being generally applicable, they require parentheses and operator precedence (otherwise, their familiarity is subverted), each of which add complexity to the language. I think that makes avoiding them the right call for Caterpillar.

<< previous thoughtnext thought >>