Decrement Tab Property

If the next statement tab number is less than LW Python's internal tab number, then a code block has ended. If the block that ended was an "if" block, LW Python is going to decrement its internal tab number 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 k = s
  • k < j
  • value at (j - 1) in map (Control Map at time t) = pair ("if", if_value)

then the tab at time (t + 1) = j - 1

For example, if the following are true:
  • the line at time 14 = 4
  • the tab at time 14 = 1
  • statement at line 4, tab 0 = c = 5
  • value at (1 - 1) in map (Control Map at time 14) = pair ("if", False)

then the tab at time (14 + 1) = 1 - 1

After LW Python executes line 3, it is in tab 1, but in line 4, the tab is 0. At this point, the "if" block has ended. Try stepping through the simulator to see LW Python decrement the tab from 1 to 0.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments