User Tools

Site Tools


Repeated Execution of -join-

The following is an example of the repeated execution of a -join- in regular, judging, and search states (remember that -join- is similar to -do-):

unit multy calc i⇐0 arrow 1514 join i⇐i+1,ansdog endarrow at 2514 show i * unit ansdog answer dog write Bowwow!

The conditional -join- has only one unit listed, so we will always join unit “ansdog” no matter what value the expression (i i-F1) has. Upon first entering unit “multy”, we do the -talc-, the -arrow-, and the -join-, all in the regular state. This terminates at the -answer- command to await a student response. Note that i is now 1, due to the assignment 1) contained in the conditional -join-. Suppose the student types “cat” and presses NEXT. TUTOR starts at the statement following the -arrow- and executes the -join- in the judging state (incrementing 1 to 2 in the process). No match is found for “cat”, so the student must give another response. Suppose the student now enters “dog”. TUTOR again starts judging just after the -arrow- and again executes the -join- (thus incrementing i to 3). This time there is a match to “answer dog” which changes the state from judging to regular. The “write Bowwow!” is executed, and the end of unit “ansdog” causes TUTOR to “undo” back into unit “multy”, where the -endarrow- signals the end of the statements associated with the -arrow-. Since we received an “ok” judgment, we are ready to search for any other -arrow-s that might be in unit “multy”. We return to the -arrow- one last time, this time in the search state. The -joinis executed to see whether there is an -arrow- command in unit “ansdog”, with the incidental result that i gets incremented to 4. No -arrow- is found in unit “ansdog” and we “undo” into the -endarrow- command, which changes us from search state to regular state. The -at- and -show- are executed and we get “4” on our screen, due to the quadruple execution of the -join-.

Aside from illustrating some consequences of the processing rules, this example should emphasize that using the assignment symbol ( ) in a conditional -join- may have unexpected results. Note that -join- is the only command with these properties, due to the fact that it is the only command executed in regular, judging, and search states. It is important that -join- be universally executed in this way so that you can join judging commands in the judging state and even -arrow- commands in the search state, not just regular commands in the regular state.

Judging Commands Terminate Regular State

The rule that a judging command terminates the processing of regular commands is an important and general rule. We have seen that this must be true upon first encountering an -arrow- (the first judging command after the -arrow- makes TUTOR wait for a student response, since that judging command needs a response to work on). Let's see another instance of the rule:

. . . arrow 1518 answer dog write Bowwow wrong cat write Meow wrong horse . . .

If the student says “dog”, he or she gets a reply “Bowwow” and regular processing stops at the “wrong cat” because -wrong-, a judging command, terminates the regular state. Similarly, if the student response is “cat”, the statement “write Meow” is the only regular statement which is executed. The judging commands delimit those regular commands associated with a match of a particular judging command. This delimiting effect is achieved because:

  1. Regular commands are skipped in the judging state; and
  2. The processing of regular commands ends whenever a judging command is encountered.

Now let's consider a slightly modified sequence:

. . . arrow 1518 join dogcat write Meow wrong horse . . . unit dogcat answer dog write Bowwow wrong cat

Supposedly, the “join dogcat” will act as though the statements of unit “dogcat” were inserted where the -join- is, which should make this modified version equivalent to the earlier version. Indeed, the rule that a judging command terminates the processing of regular commands does make the two versions equivalent, as we will show. Remember, in this discussion, that -join- is the same as -do- except for the universal nature of -join-.

Suppose the student types “dog”. We start just after the -arrow-, in the judging state. The -join- is executed and we find a matching “answer dog” which ends judging and puts us in the regular state. The “write Bowwow” is executed. The statement “wrong cat” is encountered next. The judging command -wrong- stops the processing of regular commands and also prevents coming out of the joined unit. Even though we are one level deep in -join-s, TUTOR will not “unjoin” and the “write Meow” which follows the “join dogcat” will not be executed. What will happen is just what happens in the earlier version: we have an “ok” judgment which causes the search state to be initiated at the -arrow- (there was no -specs-). Thus, the two versions operate in identical manners because the -join- acts like a text insertion. Note that a response of “cat” will get a reply “Meow” because there is no judging command following the “wrong cat” (and a normal “undo” is performed at the end of unit “dogcat”).

This last example illustrates the importance of the rule “a judging command terminates the regular state.” It is this rule which insures that -join- (or -do-) will act like a text insertion.

In the discussion of the -goto- command in Chapter 6, we saw that a -goto- in a done unit destroys the strict text insertion character of the -do-. This is true in the present context as well. Suppose we insert a -goto- in unit “dogcat” (any -goto- will do, we'll use a “goto q”):

unit dogcat answer dog write Bowwow goto q wrong cat

The student enters “dog” and we do unit “dogcat” where the match to “answer dog” flips us from the judging to the regular state. The regular commands -write- and -goto- are executed. (Note that -goto-, like -do-, is only regular whereas -join- is universal, being executed not only in regular but in judging and search states.) The execution of the -gotoprevents TUTOR from encountering the “wrong cat” which previously terminated the regular state. We have run out of things to do in unit “dogcat” and are one level deep in -do-s. TUTOR, therefore, “undoes” and executes the “write Meow” which follows the “join dogcat”! The student will see “BowwowMcow” on the screen. If, on the other hand, we replace the “join dogcat” with the statements contained in unit “dogcat” we would have:

. . . arrow 1518 answer dog write Bowwow goto q wrong cat write Meow wrong horse . . .

and a response of “dog” would merely cause “Bowwow” to appear on the screen, not “BowwowMeow”.

We have again seen that a -goto- in a done unit can cause the -joinoperation to behave differently from a text insertion. We get different effects depending on whether we -join- such a unit or put that unit's statements in place of the -join- statement. You can avoid confusion by not using -goto- commands in “done” or “joined” units which contain -arrow- commands or judging commands.

The -goto- is a Regular Command

plato/tutor/repeated_execution_of_join.txt · Last modified: 2023/08/05 18:55 by Site Administrator