diff options
Diffstat (limited to 'content/zettel/1b2.md')
-rw-r--r-- | content/zettel/1b2.md | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/content/zettel/1b2.md b/content/zettel/1b2.md index 150523f..c0b9e07 100644 --- a/content/zettel/1b2.md +++ b/content/zettel/1b2.md @@ -4,7 +4,7 @@ author = "Yann Herklotz" tags = [] categories = [] backlinks = ["1d1", "1b1"] -forwardlinks = ["3a", "1b1", "1b3"] +forwardlinks = ["3a", "1b3"] zettelid = "1b2" +++ @@ -33,39 +33,6 @@ to support a subset of possible recursive functions. Even though these are as powerful as loops, it may be more natural to write their definitions as a recursive function instead of a loop. -{{< transclude-1 zettel="1b1" >}} - -Guarded commands \[2\] are an interesting construct which can be added -to languages. They look similar to `case` statements, but behave in a -parallel and nondeterministic way. Each guard has a boolean value -followed by a program which may be executed if the guard evaluates to -true. The following shows the main syntax that guards may have. - -``` grammar -e ::= if gc fi | do gc od ... - -gc ::= (b e) || gc -``` - -One reason these are interesting language constructs, is because they -allow for the encoding of commands that may be executed when a condition -is true, but that it isn't necessary. Often, when giving instructions, -one does not really specify the order, just the commands that should -eventually be executed. - -The guarded commands `gc` will either return a match if a boolean -evaluates to true, or `abort`. There are two constructs that are built -around guarded commands which adds more functionality to them. -`if gc fi` matches one rule in the guarded statement and executes it. If -it does not match a rule, it then acts like `abort`. `do gc od` loops -over the guarded commands while any rule matches. If there no match is -found, it acts like `skip`. - -These allow for nice encoding of common algorithms, using two other -constructs that use the guarded commands. - -{{< /transclude-1 >}} - <div id="refs" class="references csl-bib-body" markdown="1"> <div id="ref-leroy06_formal_certif_compil_back_end" class="csl-entry" @@ -81,14 +48,6 @@ doi: [10.1145/1111037.1111042].</span> </div> -<div id="ref-winskel93" class="csl-entry" markdown="1"> - -<span class="csl-left-margin">\[2\] -</span><span class="csl-right-inline">G. Winskel, *The formal semantics -of programming languages: An introduction*. MIT press, 1993.</span> - -</div> - </div> [\#3a]: /zettel/3a |