-
Notifications
You must be signed in to change notification settings - Fork 23
CAD-4750 generalise OrElse frame #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request |
amesgen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice simplification! Only a few minor comments.
Note that I did not comment on the IOSimPOR part it is identical to IOSim in this case (which makes sense as this code is not scheduling-related).
amesgen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
nfrisby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. I offered a couple minor/optional suggestions.
Though I suggest getting @coot 's review before merging.
9683782 to
6bf6856
Compare
coot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks! I'd only would make BranchStmA a strict field (as suggested by @nfrisby): since we are providing another level of abstraction / indirection, making this field strict will eliminate the thunk before IOSim would evaluate it.
|
resolves IntersectMBO/ouroboros-network#1461 |
e38dcf0 to
d329b00
Compare
coot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
OrElseLeftFrame and OrElseRightFrame represent a control structure that has a alternative branch that is executed when `retry` is applied. A `catch` has a similar execution model when a `throw` is applied. The control frame is generalised to BranchFrame that can hold an alternative statement. If the execution context is `left` side of the branch then the BranchFrame contains `right` statement. When we are executing in the `right` context, the branch frame contains an empty statement.
d555c48 to
ccc84f8
Compare
OrElse and Catch have similar control semantics. Both have alternate branches that needs to be considered when a certain condition is encountered (retry in OrElse, throw in Catch). This commit tries to generalise OrElseLeftFrame/OrElseRightFrame to handle these control semantics in a similar fashion.
The commit introduces
BranchFramethat indicates that a branch has an alternate execution that is indicated by either a "statement" (OrElseStmA) or an empty statement (to indicate that there is no alternate execution left, this replaces OrElseRightFrame).This should allow adding
Catchto IO-Sim a relatively easily, than introducing a new frame to handle Catch separately.