-
Notifications
You must be signed in to change notification settings - Fork 269
Description
The method manage_block_stack
https://github.com/nedbat/byterun/blob/master/byterun/pyvm2.py#L246-L307
mentions 4 different block types.
- loop
- finally
- setup-except
- with
and 5ldifferent whys
- yield
- continue
- break
- exception
- return
Maybe after closures this is the second hardest piece of code to understand. Of course there is lots of documentation on the web.
Generally Blocks are pretty obvious. Every time I indent, I create a block. I have to add them to the block stack. Understanding what happens with an exception is a bit harder to grok.
But this code really tangles them all together. There is not even a Block class, just a named tuple.
Block = collections.namedtuple("Block", "type, handler, level")
From a conceptual point of view, I think it would be much easier to create 4 different Block classes. Maybe they would have a shared base class. It would certainly be much easier to document.
I can understand why cPython did it this way. But my goal here is to understand the concepts, before I try to understand the optimizations.
So may I write the documentation as 4 different block classes? If I eventually write those classes, would you accept a pull request?
Warm Regards
Chris