You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Transformers often have certain preconditions that need to be enforced. For this, it is convenient to have only when statements, such as:
only when x >= y
This is actually not difficult to implement, because of how flows work (specifically, how they fail when the desired values cannot be selected). So we can implement this by expanding it into:
x --[ y ]-> x
Similarly, we can expand a precondition like (where sender : address and owner : address):
only when sender = owner
into
sender --[ owner ]-> sender
Finally, we can expand compound preconditions like
only when P and Q
into
only when P
only when Q
then generating code as before. The full grammar, at least for the initial version, should be (where L is any locator; specifically, a source locator, but we can worry about that later):
Precondition ::= "only" "when" Pred
Pred ::= Pred "and" Pred | L Op L
Op ::= < | > | <= | >= | = | != | in
Ideally, we can also optimize the generate code so that no transfer actually needs to take place, and instead we can simply check the preconditions. This may require some changes to the compiler to make things work out nicely, but it is also likely that such changes will make implementing other features (such as consume) work out more nicely.
The text was updated successfully, but these errors were encountered:
Transformers often have certain preconditions that need to be enforced. For this, it is convenient to have
only when
statements, such as:This is actually not difficult to implement, because of how flows work (specifically, how they fail when the desired values cannot be selected). So we can implement this by expanding it into:
Similarly, we can expand a precondition like (where
sender : address
andowner : address
):into
Finally, we can expand compound preconditions like
into
then generating code as before. The full grammar, at least for the initial version, should be (where
L
is any locator; specifically, a source locator, but we can worry about that later):Ideally, we can also optimize the generate code so that no transfer actually needs to take place, and instead we can simply check the preconditions. This may require some changes to the compiler to make things work out nicely, but it is also likely that such changes will make implementing other features (such as
consume
) work out more nicely.The text was updated successfully, but these errors were encountered: