If Test True Store Property

If the "if" statement test evaluated to True at time t, then store the current tab number and "True" 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 = True

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

If the "if" statement test is True, then LW Python will remember this in the "Control" map. Later, when Python encounters an "else" statement, It looks at 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__(3, 3):
  • expression state at time 10 = "end_expr"
  • Return Value at time 10 = True

then Control Map at time (10 + 1) = result of storing (pair ("if", True)) at key: 0 in map: (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 into the "Control" map.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments