P comes after C in BCPL # continue case For multiply defined cases, every one but the last has to end in continue case as not to break fallthrough. switch(foo){ case A: case B: common code for A and B; continue case; // go to second case A/B case A: code for A; break; case B: code for B; break; case C: code for C; break; } # for else for(i = 0; i < n; i++){ if(i == 5) break; // found }else error(EGREG); // not found // break goes here, value was found # break out of if while(...){ if(foo){ if(bar){ break; // break1 break 0; // break2. break out of if, skip 0 blocks break 1; // break3. skip 1 block } // break2 goes here. }else{ // TODO: how to get here? } // break3 goes here } // break1 goes here # value blocks hard to implement because of type. Infer block type if all returns are the same type? # lambdas (experimental) Harder to implement because closures make memory management difficult. Not thought through yet. int (*)(void) mkadder(void) { int c = 0; return int ->(void){ // c is captured in closure // every call allocates a new environment // function pointer is a thunk of environment + function code // both need to be free'd return c++; } } void foo(void) { int (*adder)(void) = mkadder(); adder(); // returns 0 adder(); // returns 1 lfree(adder); } # continuations (requires lambda) void (*cont)(int); // of type lambda continue int foo(int a, int b) { cont = (->)continue; return 123; } void bar(void) { // calls with continuation due to type of foo bar = foo(x, y); // 123 initially // do stuff cont(3); // return again, 3 this time }