Child Function Call Returned Property

If the state is "call_returned" and the parent stack contains one or more elements at time t, then at time t + 1, the state is "return." More formally,

if the following are true:
  • expression state at time t = "call_returned"
  • parent stack at time t = [ x, y ]

then expression state at time (t + 1) = "return"

After Python has returned from the function body, the function call has finished. If the parent stack was not empty, then the current expression was an argument (child). Thus the returned value is used as an argument value to the parent function call, and the expression evaluation continues.

For example, if the following are true:

  • expression state at time 27 = "call_returned"
  • parent stack at time 27 = [ add_three((add_three(a))), [ ] ]

then expression state at time (27 + 1) = "return"

Try stepping through the simulator to see the state change to "return."

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments