Files
badvpn/ncd/tests/backtracking.ncd
Ambroz Bizjak f20999da62 ncd: Reverse the immediate effect logic of backtrack_point::rgo().
Turns out we want the backtrack triggering effects to have priority. Consider the following test case.

process main {
    backtrack_point() pointA;
    println("A");
    sleep("1");
    If ("true") {
        backtrack_point() pointB;
        println("B");
        pointA->rgo();
        pointB->go();
    };
}

The result of this would originally have been "A B B B B...". The reason is that the If process would be caught in an infinite loop, and the main process would never get a chance to backtrack past the If statement. With this change, the result is "A B A B...", since the rgo() deinitialization immediately causes backtracking in main.

This is actually a nice example about a design bug regarding the subtle ways in which a process call (If, in this case) is not equivalent to embedding the statements in place. Without the If, there would not be an infinite loop in any case.
2014-12-07 00:30:12 +01:00

1.2 KiB