From a6ffd914f9ffff4b7ba1ca9e674316a27399b143 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 25 Sep 2023 23:32:11 -0400 Subject: [PATCH] Define conditional statements Fixes #180. --- infra.bs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/infra.bs b/infra.bs index 1a91b69..69878d2 100644 --- a/infra.bs +++ b/infra.bs @@ -557,6 +557,49 @@ the end result is indistinguishable. For instance, as long as |result| in the ab mutated during a compute operation, the user agent could stop the computation. +

Conditional statements

+ +

Algorithms with conditional statements should use the keywords "if", "then", and "otherwise". + +

+
    +
  1. Let |value| be null. + +

  2. If |input| is a string, then set |value| to |input|. + +

  3. Return |value|. +

+
+ +Once the keyword "otherwise" is used, the keyword "then" is omitted. + +
+
    +
  1. Let |value| be null. + +

  2. If |input| is a string, then set |value| to |input|. + +

  3. Otherwise, set |value| to failure. + +

  4. Return |value|. +

+
+ +
+
    +
  1. Let |value| be null. + +

  2. If |input| is a string, then set |value| to |input|. + +

  3. Otherwise, if |input| is a list of strings, set |value| to |input|[0]. + +

  4. Otherwise, throw a {{TypeError}}. + +

  5. Return |value|. +

+
+ +

Iteration

There's a variety of ways to repeat a set of steps until a condition is reached. @@ -2051,6 +2094,7 @@ Malika Aubakirova, Martin Thomson, Michael™ Smith, Mike West, +Mike Taylor, Ms2ger, Pavel "Al Arz" Kurochkin, Philip Jägenstedt,