Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Line 7 can't be the first to execute because its defer expression initially evaluates to true.

The longer version:

  • "In some cases, the statement will contain a clause that specifies that it cannot be executed until certain conditions apply. This results in the statement being deferred and placed back on the to-do list."
  • "The defer statement takes a boolean argument. If the argument is true, the statement is deferred - i.e. the remainder of the statement is not executed and the line number of the defer statement remains on the to-do list."
  • "The following standard [...] boolean operators work as expected: [...] &&, ||, !."
  • "An integer used in a boolean context evaluates to false if the line of that number is not currently on the to-do list and to true if it is on the to-do list at least once."

The initial to-do list includes all lines so all defer expressions evaluate to true:

  • Line 2: (T && T) --> T
  • Lines 4 and 8: (T || T) --> T
  • Line 5: ((T || !T) && T) --> T
  • Line 7: (T || !T) --> T

Therefore, the executable lines are {1,3,6}. Executing lines 3 and 6 any number of times doesn't modify the to-do list, so they can be ignored (except for determining halting). "Eventually", line 1 will be picked, executed and removed from the to-do list.

Once that is done, the defer exression of line 2 will be the only one that evaluates to false:

  • (1 && 7) --> F && T --> F

Therefore, the executable lines will be {2,3,6}, line 2 will ultimately get picked, and "A B" will be printed.

Then, depending on whether read() returns 1 or 0, we'll have a to-do list of either [3,4,5,6,7,8] or [4,5,6,7,8], the executable lines will be either {3,5,6} or {4,6}, and either "D E" or "C" will get printed (all respectively). And so on...