They're not equations; they're assignments. Don't confuse =
for a mathematical equality symbol. It's an assignment operator. It assigns the RHS to the LHS.
Imagine that the assignment operator were ←
instead of =
. Then this would assign the result of add_10(30)
to a variable named add_30
:
add_30 ← add_10(30)
And this would... assign add_30
to the function call add_10(30)
? What the heck does that mean? It doesn't exactly make sense, does it?
add_10(30) ← add_30 # huh?
Indeed, I too was confused about =
when I first started programming. We programmers are all quite used to =
nowadays, but it wasn't necessarily the best choice back in the 70's when C was invented. In fact, Pascal—which was designed as a teaching language—deliberately invented a new, non-symmetric assignment operator so as not to confuse math students. =
was the equality operator rather than assignment.
add_30 := add_10(30)
if add_30 = 40 then ...
Too bad it didn't catch on. C won the influence wars and most modern languages base their syntax on C, so =
for assignment it is.