Crosscut

Daily Thought - 2024-05-10

Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

This thought was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.

< back to list

I've been talking about postfix operators for days now. If you've already been familiar with them before, then you might be surprised that I haven't mentioned the stack once. I did that to keep my explanations simple, but also to make a point. We can develop an intuition for this, without constantly thinking about the stack.

For those not familiar, the evaluation model behind postfix operators is a stack. Let's consider a simple math example again, 1 2 +. We can say that 1 is a function which puts 1 on the stack. The stack contains 1 afterwards. After 2, the stack contains 1 2. + is a function that takes two numbers from the stack, and puts their sum back (the stack contains 3 afterwards).

The stack is important. It's how this model is implemented behind the scenes, and it's a method for understanding how it works. But my point is, we don't need to constantly think (and talk!) about the stack. Just like we don't constantly think and talk about graphs, when working with operations involving infix operators.

<< previous thoughtnext thought >>

Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email whenever I post a new one.