Playing around with generators, and have come across a strange oddity. This code works fine:
continue int gen(int x) { if (x == 1) continue return 1; if (x == 1) continue return 2; if (x == 1) continue return 3; return 4; }
int main() { function foo = gen(1); while (1) { int i = foo(); if (undefinedp(i)) break; write("%d\n", i); } }
But remove any of the 'if' guards, and the function terminates prematurely.
continue int gen(int x) { if (x == 1) continue return 1; continue return 2; if (x == 1) continue return 3; return 4; }
This will print out 1, 2, 0, and then halt. It appears that perhaps an unconditional 'continue return' causes subsequent code to be eliminated as if following a hard 'return' statement?
ChrisA