Oct 15-20, 2003 ------------- - Oct 15 - midterm - Oct 17 - midterm return - discussion of questions and solutions - Oct 20 - feedback form review - more discussion - Control - guarded ifs and guarded dos - Format of a guarded if - if B1 -> S1 | B2 -> S2 | B3 -> S3 | .... | Bn -> Sn fi - Semantics of a guarded if - if exactly one B is true, corresponding S is performed - if more than one B is true, one and exactly one S is performed - if none of the Bs are true, - Notice that - order of evaluation of Bs is left unspecified - how a S must be chosen when more than one B is true, is also unspecified => a non-deterministic construct - Manifestations of guarded ifs in today's languages - if-then-else - danging else problem - can update grammar, or - use "fi" type of closing constructs - case construct - example from C - use of break, to break out of conditions - "collapsing" efects for multiple statements - Format of a guarded do - do B1 -> S1 | B2 -> S2 | B3 -> S3 | .... | Bn -> Sn od - Semantics of a guarded do - akin to guarded if, except when none of the Bs are true, skip out (not a runtime error) - Manifestations of guarded dos - while - repeat - for - examples from C - how while satisfies the guarded do conditions - Simulating repeat using while - how for satisfies the guarded do conditions