Re: [Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-15 Thread Eugene Toder
I think you guys are forgetting about FOR_ITER, listcomps, and the like. That is, IIRC, the reason loops use the block stack is because they put things on the regular stack, that need to be cleared off the stack when the loop is exited (whether normally or via an exception). Good point.

Re: [Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-12 Thread Antoine Pitrou
Hello, Am I missing something? Does SETUP_LOOP serve any other purpose? Not to my knowledge. Similarly, it looks like BREAK_LOOP and CONTINUE_LOOP are just jumps that respect try/finally blocks (i.e. jumping out of try executes finally). Is there more semantics to them than this? There

Re: [Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-12 Thread Eugene Toder
There are also with blocks :-) (which use separate opcodes, although they are similar in principle to try/finally blocks) IIUC they use separate opcode, but the same block type (SETUP_FINALLY). There may be complications with nested try/finally blocks. You either need to generate separate

Re: [Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-12 Thread P.J. Eby
At 08:25 AM 3/12/2011 -0500, Eugene Toder wrote: Right, I'm not suggesting to remove all blocks, only SETUP_LOOP blocks. Do you see the problem in that case? I think you guys are forgetting about FOR_ITER, listcomps, and the like. That is, IIRC, the reason loops use the block stack is because

[Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-11 Thread Eugene Toder
Hello, What is the purpose of SETUP_LOOP instruction? From a quick look it seems like it just pushes the size of the loop into blocks stack; that size is only used by BREAK_LOOP instruction. BREAK_LOOP could just contain the target address directly, like CONTINUE_LOOP does. This would avoid