Question: When we use substitution model to evaluate a program involving assignment statement, I'm not quite sure when to substitute. For example in the case below, when we pass an argument 25 to the parameter balance, then in the "balance = balance - amount" part, only the second occurrence of balance is replaced by 25, while the first one doesn't change. Why is this the case? What is a general rule of replacing the parameter with the actual argument?
Answer: The central idea of Lecture L7 was that the substitution model breaks down when you have assignments. In other words, you should not and cannot use the model for programs that have assignments.
Question: When we use substitution model to evaluate a program involving assignment statement, I'm not quite sure when to substitute. For example in the case below, when we pass an argument 25 to the parameter balance, then in the "balance = balance - amount" part, only the second occurrence of balance is replaced by 25, while the first one doesn't change. Why is this the case? What is a general rule of replacing the parameter with the actual argument?
Piazza: https://piazza.com/class/kas136yscf8605?cid=520