Exercise 2: Why WS-CURRENT-STEP Genuinely Needs to Exist for the EVALUATE Rewrite — Possible Solution ==================================================================== WHAT THE ORIGINAL ALTER VERSION'S OWN REAL STATE ACTUALLY WAS In this chapter's own original ALTER example, the "memory" of which step should run next wasn't stored in any real data field at all - it was stored implicitly, inside PROCESS-PARA's own GO TO statement itself, in the form of whatever paragraph name that GO TO currently pointed to. ALTER's whole real mechanism works by rewriting that target destination directly, using the GO TO statement's own real target as the place where "which step comes next" is remembered. WHY EVALUATE HAS NO EQUIVALENT PLACE TO STORE THAT SAME INFORMATION EVALUATE, unlike GO TO, doesn't have a real, rewritable "target" the way a GO TO statement does - it's a real, structured statement that picks one branch to execute based on comparing a real data value against a set of WHEN conditions. There's no real mechanism resembling ALTER available to EVALUATE at all; it has nothing analogous to a GO TO's own destination that could be silently modified from elsewhere. WHY A REAL, SEPARATE FIELD IS GENUINELY NECESSARY INSTEAD Since EVALUATE decides its own real branch by testing a value, and the original version's own "next step" information can no longer live inside a rewritable GO TO target, that same information has to be moved somewhere EVALUATE can genuinely test it - a real, ordinary WORKING-STORAGE field. This chapter's own rewrite introduces WS-CURRENT-STEP specifically to hold that value explicitly, and moves "B" into it at the exact point the original version's own ALTER statement used to silently rewrite the GO TO target. WHY THIS GENUINELY REPRODUCES THE ORIGINAL BEHAVIOR By storing "A" as the field's own real starting value and updating it to "B" once STEP A's processing completes, WS-CURRENT-STEP genuinely recreates the same real progression the ALTER version produced - STEP A processing runs first, then STEP B processing runs on the next execution - but now through a value EVALUATE can directly and visibly test, rather than through an invisible, rewritten GO TO destination. ANSWER: WS-CURRENT-STEP needs to exist as a real, separate field because the original ALTER version stored "which step runs next" implicitly inside PROCESS-PARA's own GO TO target, and EVALUATE has no equivalent rewritable destination it could use the same way - it can only test a real, explicit data value. Introducing WS-CURRENT-STEP gives EVALUATE something concrete to test, and moving "B" into it where the original ALTER statement used to run reproduces the same real progression from step A to step B, just through a visible field instead of a silently modified GO TO target. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly identifies that ALTER's own real mechanism stored state implicitly in a GO TO's target, while EVALUATE requires that same state to be made explicit in a real data field, and explains why the rewrite's own placement of the field update reproduces the original version's behavior.