Skip to content
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

Add and explain usage of "abort these steps" #255

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,33 @@ will make the caller automatically rethrow the given value, if any, and thereby
caller's algorithm. Using prose the caller has the ability to "catch" the exception and perform
another action.

<p>Algorithms often involve passing a set of steps as an argument to some other algorithm. In
these cases, use "abort these steps" to indicate that the passed set of steps should terminate,
without affecting the larger algorithm. Do not use "return" for this, as "return" is only used for
terminating the larger algorithm.

<div class=example id=example-abort-these-steps>
<p>To bake a cake:

<ol>
<li><p>Gather the ingredients.
<li><p>If you are missing crucial ingredients, then return.
<li><p>Preheat the oven.
<li>
<p>Ask your partner to complete the following steps:
<ol>
<li><p>Cream the butter and sugar.
<li><p>Add the eggs and flour.
<li><p>If there is no vanilla, then abort these steps.
<li><p>Add vanilla.
</ol>
</li>
<li><p>Stir in the flour.
<li><p>Pour the batter into the pan.
<li><p>Put the cake in the oven for an hour.
</ol>
</div>


<h3 id=algorithm-conditional-abort>Conditional abort</h3>

Expand Down Expand Up @@ -1425,6 +1452,7 @@ Daniel Ehrenberg,
Dominic Farolino,
Jake Archibald,
Jeff Hodges,
Jeremy Roman,
Jungkee Song,
Leonid Vasilyev,
Maciej Stachowiak,
Expand Down