Else Statement Line Property

If the current statement is an "else" statement, and the corresponding "if" statement tested False, then increment the line by 1. 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 = else:
  • value at j in map (Control Map at time t) = pair ("if", False)

then the line at time (t + 1) = i + 1

If the "if" statement previously tested False, then the "else" statement body will be executed. The "else" body starts right after the "else" statement, so increment the line number by 1.

For example, if the following are true:

  • the line at time 12 = 3
  • the tab at time 12 = 0
  • statement at line 3, tab 0 = else:
  • value at 0 in map (Control Map at time 12) = pair ("if", False)

then the line at time (12 + 1) = 3 + 1

The "Control" map indicates that at tab 0, there was an "if" statement that tested false. Try stepping through the simulator to see LW Python increment the line number by 1.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments