Michael Fischer: # On Nov 04, Brent Dax <[EMAIL PROTECTED]> took up a keyboard # and banged out # > Michael Fischer: # > # In the goto case, we spin. And perhaps I am broken there. End # > # really wants to return, not just set the pc, but I hadn't thought # > # of a clever way to do that corner case, and wanted to see what # > # the behavior would be without it. I suspect I need it. # > # > Can't you just break()? # # Out of a function?
Isn't the win in computed goto that you inline the sub bodies and can loop implicitly instead of explicitly, thus saving a jump or two? goto *lookup[*pc]; op0: return; op1: pc += 1; goto *lookup[*pc]; op2: /* whatever */ pc += size_of_op_2; goto lookup[*pc]; op3: /* this one may halt */ if(whatever) { pc += size_of_op_3; goto lookup[*pc]; } else { return; } vs. while(pc) { goto *lookup[*pc]; op0: pc=Parrot_op_end(pc, interp); continue; op1: pc=Parrot_op_noop(pc, interp); continue; op2: pc=Parrot_op_whatever(pc, interp); continue; op3: pc=Parrot_op_whatever_else(pc, interp); continue; ... } The second example really is no better than a switch (and perhaps worse, since the compiler can't get a high-level view of things and maybe come up with a better way to do it). --Brent Dax [EMAIL PROTECTED] Configure pumpking for Perl 6 When I take action, I'm not going to fire a $2 million missile at a $10 empty tent and hit a camel in the butt. --Dubya