If Test False Property

If the "if" statement test evaluated to False at time t, then store the current tab number and "False" to the "Control" map. More formally,

if the following are true:
  • the line at time t = i
  • the tab at time t = j
  • statement at line i, tab j = if test:
  • expression state at time t = "end_expr"
  • Return Value at time t = False

then Control Map at time (t + 1) = result of storing (pair ("if", False)) at key: j in map: (Control Map at time t)

If the "if" statement test is False, then Python will remember this in the "Control" map. When Python encounters an "else" statement, It looks at the top of the "Control" map to see whether the corresponding "if" statement tested true or false.

For example, if the following are true:

  • the line at time 10 = 1
  • the tab at time 10 = 0
  • statement at line 1, tab 0 = if __eq__(1, 3):
  • expression state at time 10 = "end_expr"
  • Return Value at time 10 = False
  • Control Map at time 10 = [ ]

then Control Map at time (10 + 1) = [ pair ("if", False), Control Map at time 10 ]

The key is the current tab number, and the value is the pair "if":True. Try stepping through the simulator to see LW Python set the new pair in the "Control" map.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments