Daily Thought - 2024-05-10
< back to listI'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.