Variable binding: (re-) assignment, argument passing, `let`, scope

(he is always right, even though it is sometimes necessary to meditate on his words).

I’m sure you wanted to say he is most often right. NO ONE IS ALWAYS RIGHT
(& I’m not implying anything about him, either from this thread or in general).
I’m emphasizing this because it’s important to uphold preserve the culture that we have at least in western world, that one should always question any authority, if he/she thinks so (of course with due respect). Else, sooner or later a mistake surfaces, and the more people believe without questioning, the graver the consequences.

Relative to you or yuyichao, I have next to nothing specific compiler knowledge. But here’s what I understand, by an analogy.
Say I’m given that:

x= 234 *2342
y=908 - x
y= 234 +1001
z= 3*(y+ 23 -23 -23 -23 +23 +5)/(3*1000*y)

And I’m asked to what is z.
Then I break the solving in 2 parts: simplification and actual-computation

  1. Simplification. I’ll look at what’s asked, and realize I only need y, and so ignore x completely. Also, ignore the older y.
    Then , in expression for z, I’ll try scan the expression, notice cancellations possible and do that. Eventually get an equivalent problem:
    y=234+1001
    z=(y- 23 +5)/(1000*y)
    
  2. Computation. Compute y, store result. Substitute for y in z. Finally do all operations in expression of z.

The Ist phase to me is one an optimizing compiler could do, at a very high level; and the “execution” would be 2nd step.

I can indeed see that the computer is not going to do the instructions in a top-down fashion as I presented the original program/problem, but instead take the whole program as a whole and try to give an answer that would be equivalent to running each statement in turn, but in a much smarter &faster way.
On the other hand, if given those instructions one by one, like in REPL, the computer is forced to follow them literally.

So I can see now what @yuyichao might have meant when he was saying that an instruction like x=100 may or may not result in storing 100 at some place in memory. It really depends on the other instructions next to x=100, given as a block or not, and context.

And I had in mind REPL, and 1 instruction at a time, when I was surprised to hear that; it was like a religious authority telling you that the earth is flat.

I guess in complex problems it helps to do the simplification step I mentioned above yourself, to help the compiler.