<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Syntax-Statements</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>Recent changes to Syntax-Statements</description><atom:link href="https://sourceforge.net/p/mortal/wiki/Syntax-Statements/feed" rel="self"/><language>en</language><lastBuildDate>Thu, 29 Aug 2019 04:47:44 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/mortal/wiki/Syntax-Statements/feed" rel="self" type="application/rss+xml"/><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v42
+++ v43
@@ -117,7 +117,7 @@

 To embed an `if` into a larger expression, enclose it in parentheses.

-    result = (if num &amp;lt; 10 then 10 else num) - 10
+    data = (if num &amp;lt; 10 then 10 else num) - 10

 Switch statements
 -----------------
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Thu, 29 Aug 2019 04:47:44 -0000</pubDate><guid>https://sourceforge.net9368f145bdffee8782a2a16899fc20ab01424204</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v41
+++ v42
@@ -52,7 +52,7 @@

 Expressions
 -----------
-A bare expression can be a statement. This is mainly useful if the expression is a [calls](Syntax-Expressions#calls).
+A bare expression can be a statement. This is mainly useful if the expression is a [call](Syntax-Expressions#calls).

     printf("Hello World\n")

@@ -104,6 +104,20 @@
 In such cases, however, you can usually add conditions to statements instead.

     num = 10 if num &amp;lt; 10
+
+`if` statements can be used as expressions. In this case, the last statement of both branches must be an expression to return.
+
+    result: bool = if check_status() {
+        printf("All OK\n")
+        true
+    } else {
+        printf("Failed\n")
+        false
+    }
+
+To embed an `if` into a larger expression, enclose it in parentheses.
+
+    result = (if num &amp;lt; 10 then 10 else num) - 10

 Switch statements
 -----------------
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Thu, 29 Aug 2019 04:36:14 -0000</pubDate><guid>https://sourceforge.net5c2371ac1a4d4b1549d20647cd7a8a47f80b95b9</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v40
+++ v41
@@ -4,61 +4,57 @@
 ---------
 Local variables can be used to store values or references temporarily. They are destroyed once the program execution leaves the scope they're defined in. They can be created in several ways:

-    num: int;
-
-This will define `num` as an integer, and initialize it with its default value. For integers, the default value is zero. For reference types, the default value is null. (Although it may sound inefficient to always initialize a variable when it's created, it isn't really. If the initialization turns out to be redundant, the compiler can always optimize it away later. Thus, defining predictable behaviour, to simplify coding (and avoiding bugs), is considered more important.)
-
-    num: int = 5;
+    num: int
+
+This will define `num` as an integer, and initialize it with its default value. For integers, the default value is zero. For reference types, the default value is `null`. (Although it may sound inefficient to always initialize a variable when it's created, it isn't really. If the initialization turns out to be redundant, the compiler can always optimize it away later. Thus, defining predictable behaviour, to simplify coding (and avoiding bugs), is considered more important.)
+
+    num: int = 5

 This will define `num` as an integer, and initialize it with the value 5. Any expression can be used as an initializer (as long as the types are compatible).

-    obj: File("/dev/null", "r");
+    obj: File("/dev/null", "r")

 This will define `obj` as a file object, and initialize it by calling its allocator/constructor, passing it the two given strings. In this case, the allocator will open the file `/dev/null` for reading. You can then use `obj` to read from it.

-    num: auto = 5;
+    num ::= 5

 This will define `num` as an integer because the initializer, `5`, is an integer. Only the type of the initializer matters, the type of any later assignments to the variable are not taken into account.

-    num ::= 5;
-
-If you don't need to add type qualifiers, this does the same as above, but is slightly shorter to write.
-
-    num = 5;
+    num = 5

 (UNDER CONSIDERATION) If `num` is not already defined, then this will create a new variable using the type of the initializer (integer in this case). Again, only the type of the first assignment matters, the type of later assignments are not taken into account. (This technique is not recommended for production code, because if someone later defines a global variable or class field called `num`, then your code will suddenly use it instead of creating a local variable. However, for casual programming it is offered as a convenience.)

 It's possible to declare a variable as `static`. In this case, the variable, and its value, is not destroyed before the program itself terminates. Example:

-    static num: int;
+    static num: int

 Assignments
 -----------
 Assigning to a variable copies the value or reference to it. Any expression can be assigned to the variable; the value of the expression is computed, and then copied to the variable.

-    num = 10;
-
-Note that an assignment is a *statement*, not an operator. You cannot use the equals sign like this inside expressions like you can in C. This stops inexperienced programmers from doing assignments when they mean to use the equality operator `==`, and allows the symbol to also be used for other things. (If you really want to do assignments inside expressions, you can use `:=`, the inline assignment operator.)
+    num = 10
+
+Note that an assignment is a *statement*, not an operator. You cannot use the equals sign like this inside expressions like you can in C. This allows the symbol to be used for other useful things (such as naming parameters in [calls](Syntax-Expressions#calls)), and also stops inexperienced programmers from doing assignments when they mean to use the equality operator `==`. (If you really want to do assignments inside expressions, you can use `:=`, the inline assignment operator.)

 Since the value of the expression is always computed *before* the assignment is done, it is possible to use the old value of a variable to compute a new value for the same variable.

-    num = num + 1;
+    num = num + 1

 This would increment the value of `num` by 1. This type of assignment also has a shorthand form:

-    num += 1;
+    num += 1

 Conditions can be added to assignment statements.

-    num = 10 if num &amp;lt; 10;
+    num = 10 if num &amp;lt; 10

 This will only assign `10` to `num` if it was smaller than `10` before the assignment.

 Expressions
 -----------
-A bare expression can be a statement. This is mainly useful if the expression is a call.
-
-    printf("Hello World\n");
+A bare expression can be a statement. This is mainly useful if the expression is a [calls](Syntax-Expressions#calls).
+
+    printf("Hello World\n")

 Just as with assignments, conditions can be added to expression statements.

@@ -67,97 +63,97 @@
 Any place where a single statement is accepted, it's possible to use multiple statements if they are enclosed in curly brackets. This also creates a new scope, which can hold its own local variables.

     {
-        num: int = 10;
-        printf("Hello\n");
+        num: int = 10
+        printf("Hello\n")
     }

 If statements
 -------------
-The if statement allows statements of any kind to be executed conditionally. There are several ways to write if statements. The standard way is to use compound statements.
+The `if` statement allows statements of any kind to be executed conditionally. There are several ways to write `if` statements. The standard way is to use compound statements.

     if num &amp;lt; 10 {
-        num = 10;
-    }
-
-An if statement may have an else clause, which is executed if the condition was false.
+        num = 10
+    }
+
+An `if` statement may have an `else` clause, which is executed if the condition was false.

     if check_status() {
-        printf("All OK\n");
+        printf("All OK\n")
     } else {
-        printf("Failed\n");
-    }
-
-If statements can be chained (though, in many cases, it may be better to use a switch statement instead).
+        printf("Failed\n")
+    }
+
+`if` statements can be chained (though, in many cases, it may be better to use a `switch` statement instead).

     if num == 5 {
-        printf("Found a 5\n");
+        printf("Found a 5\n")
     } else if num == 6 {
-        printf("Found a 6\n");
+        printf("Found a 6\n")
     } else {
-        printf("Found neither\n");
+        printf("Found neither\n")
     }

 Compound statements are not mandatory. Most statements that start with a keyword are recognized.

-    if num &amp;lt; 10 return num;
+    if num &amp;lt; 10 return num

 Otherwise, you can use the `then` keyword.

-    if num &amp;lt; 10 then num = 10;
+    if num &amp;lt; 10 then num = 10

 In such cases, however, you can usually add conditions to statements instead.

-    num = 10 if num &amp;lt; 10;
+    num = 10 if num &amp;lt; 10

 Switch statements
 -----------------
-Switch statements allow statements to be executed depending on the value of a variable or expression. While an if statement can only check one value at a time, a switch statement can check many. Thus, though switch statements could be emulated using if chains, switch statements are usually both more efficient and more readable.
+`switch` statements allow statements to be executed depending on the value of a variable or expression. While an `if` statement can only check one value at a time, a `switch` statement can check many. Thus, though switch statements could be emulated using `if` chains, `switch` statements are usually both more efficient and more readable.

     switch num {
     case 5:
-        printf("Found a 5\n");
+        printf("Found a 5\n")
     case 6:
-        printf("Found a 6\n");
+        printf("Found a 6\n")
     case 10, 20:
-        printf("Found a 10 or 20\n");
+        printf("Found a 10 or 20\n")
     default:
-        printf("Found neither\n");
-    }
-
-Unlike in C, there is no implicit fallthrough, so `break` statements are not needed (though they are allowed). This is because the majority of cases do not need fallthrough. (If you do need such functionality, you may use goto statements.)
+        printf("Found neither\n")
+    }
+
+Unlike in C, there is no implicit fallthrough, so `break` statements are not needed (though they are allowed). This is because the majority of cases do not need fallthrough. (If you do need such functionality, you may use `goto case` statements.)

 Each `case` is its own scope. There's no need for extra curly brackets if you need to define local variables inside a particular `case`.

 While loops
 -----------
-The while loop allows statements to be executed repeatedly as long as a condition is true. The condition is tested before every loop iteration (but not during them). The standard way to write while loops is to use compound statements.
+The `while` loop allows statements to be executed repeatedly as long as a condition is true. The condition is tested before every loop iteration (but not during them). The standard way to write `while` loops is to use compound statements.

     while num &amp;lt; 10 {
-        num = num + 1;
-    }
-
-As with the if statement, compound statements are not mandatory. Some statements that start with a keyword are recognized (but not as many as for the if statement). Otherwise, you can use the `do` keyword.
-
-    while num &amp;lt; 10 do num = num + 1;
+        num = num + 1
+    }
+
+As with the `if` statement, compound statements are not mandatory. Some statements that start with a keyword are recognized (but not as many as for the `if` statement). Otherwise, you can use the `do` keyword.
+
+    while num &amp;lt; 10 do num = num + 1

 Do-while loops
 --------------
-Do-while loops are like while loops, except that the condition is first tested after the first loop iteration, instead of before. This means that the statements are always executed at least once.
+`do while` loops are like while loops, except that the condition is first tested after the first loop iteration, instead of before. This means that the statements are always executed at least once.

     do {
-        num = num + 1;
-    } while num &amp;lt; 10;
+        num = num + 1
+    } while num &amp;lt; 10

 Or, without compound statements:

-    do num = num + 1 while num &amp;lt; 10;
+    do num = num + 1 while num &amp;lt; 10

 For loops
 ---------
-For loops come in a couple of variants. The simple one iterates over all elements in a container or range.
+`for` loops come in a couple of variants. The simple one iterates over all elements in a container or range.

     for x in the_list {
-        do_something(x);
+        do_something(x)
     }

 In this case, `the_list` is a variable referring to a container object holding a list of objects. The statements are executed once for each such object, with the local variable `x` referring to that object. The scope of the variable is only the for loop itself.
@@ -165,34 +161,34 @@
 The other variant is the C-style for loop.

     for (num=0; num&amp;lt;10; num+=1) {
-         do_something(num);
+         do_something(num)
     }

 Here, the parentheses are required. They contain three statement parts separated by semicolons. Each part is optional, but the semicolons are mandatory. The first part is a comma-separated initializer list, which can contain definitions of new variables and/or assignments to already existing variables. If a new variable is defined here, its scope is only the for loop itself. The second part is a condition. As in a while loop, it is tested before the first iteration. The third part is a comma-separated list of assignments to perform after every iteration, just before testing the condition again.

 Control flow statements
 -----------------------
-The `break` statement breaks out of a loop or switch statement. Example:
+The `break` statement breaks out of a loop or `switch` statement. Example:

     do {
         if need_to_abort() {
-            break;
+            break
         }
-        num = num + 1;
-    } while num &amp;lt; 10;
-
-The `continue` statement breaks out of the current iteration of a loop, but not the loop itself. The next iteration is prepared as normal (including any for-loop assignments, and testing of any loop condition). Example:
+        num = num + 1
+    } while num &amp;lt; 10
+
+The `continue` statement breaks out of the current iteration of a loop, but not the loop itself. The next iteration is prepared as normal (including any `for`-loop assignments, and testing of any loop condition). Example:

     do {
         if need_to_try_again() {
-            continue;
+            continue
         }
-        num = num + 1;
-    } while num &amp;lt; 10;
+        num = num + 1
+    } while num &amp;lt; 10

 The `return` statement ends execution of a function and returns the provided value, if any. Example:

-    return num;
+    return num

 As with assignments, conditions can be added to control flow statements.

@@ -201,50 +197,50 @@
 Try statements are used to recover from exceptions. Exceptions are usually thrown when some error occurs. When exceptions are thrown, normal execution aborts. If the exception was thrown in scope of a try statement which has an exception handler that matches the exception, then execution jumps to that handler.

     try {
-        risky_operation();
-        finish_operation();
+        risky_operation()
+        finish_operation()
     } catch err: IOError {
-        handle_io_error(err);
+        handle_io_error(err)
     }

 The above will catch any `IOError` exceptions thrown by `risky_operation` or `finish_operation`, and recover from them by calling `handle_io_error`. (If the exception was thrown by `risky_operation`, then `finish_operation` is not executed.) Other types of exceptions are not caught.

     try {
-        risky_operation();
-        finish_operation();
+        risky_operation()
+        finish_operation()
     } catch {
-        handle_any_error();
+        handle_any_error()
     }

 The above will catch any exception, no matter what type. However, there's no way to determine the type of exception, so this should only be used as a last-resort handler. For example:

     try {
-        risky_operation();
-        finish_operation();
+        risky_operation()
+        finish_operation()
     } catch err: IOError {
-        handle_io_error(err);
+        handle_io_error(err)
     } catch {
-        handle_any_error();
+        handle_any_error()
     }

 The above handles `IOError` by calling `handle_io_error`, and also handles all other types of exceptions by calling `handle_any_error`.

     try {
-        risky_operation();
+        risky_operation()
     } finally {
-        finish_operation();
+        finish_operation()
     }

 The above forces `finish_operation` to be called even if an exception is thrown by `risky_operation`. However, it does not actually catch the exception. If this try statement is executing within another try statement, then the exception is passed to the outer try statement after calling `finish_operation`.

     try {
-        risky_operation();
+        risky_operation()
     } finally {
-        finish_operation();
+        finish_operation()
     } catch err: IOError {
-        handle_io_error(err);
+        handle_io_error(err)
     } catch {
-        handle_any_error();
+        handle_any_error()
     }

 The above combines all of the described handlers. If an exception is thrown from `risky_operation`, then `finish_operation` is called anyway, after the appropriate exception handler. (However, exceptions thrown by `finish_operation` will not be handled by this try statement.)
@@ -253,21 +249,21 @@
 ---------------
 (NOT IMPLEMENTED YET)

-Goto statements can be used to cause execution to jump directly to some given point inside a function. They are subject to several restrictions. For example, you are, in general, not allowed to jump directly into a scope you're not already in. Most of the time, goto statements should be avoided in favour of other language features (like control flow statements, or exceptions and try statements), but sometimes they are useful.
+`goto` statements can be used to cause execution to jump directly to some given point inside a function. They are subject to several restrictions. For example, you are, in general, not allowed to jump directly into a scope you're not already in. Most of the time, `goto` statements should be avoided in favour of other language features (like control flow statements, or exceptions and try statements), but sometimes they are useful.

 Goto statements come in a couple of variants. The regular one requires that you explicitly declare jump targets using `label`:

-    label my_label;
-    num = num + 1;
-
-    goto my_label;
-
-There's also a variant that can be used inside switch statements:
+    label my_label
+    num = num + 1
+
+    goto my_label
+
+There's also a variant that can be used inside `switch` statements:

     switch num {
     case 5:
-        printf("Handle 5\n");
-        goto case 6;
+        printf("Handle 5\n")
+        goto case 6
     case 6:
-        printf("Handle 5 or 6\n");
-    }
+        printf("Handle 5 or 6\n")
+    }
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Sun, 25 Aug 2019 20:22:35 -0000</pubDate><guid>https://sourceforge.netd82baf0c5e2c42ea5fb3cff1b6fa1b46016dacca</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v39
+++ v40
@@ -26,7 +26,7 @@

     num = 5;

-If `num` is not already defined, then this will create a new variable using the type of the initializer (integer in this case). Again, only the type of the first assignment matters, the type of later assignments are not taken into account. (This technique is not recommended for production code, because if someone later defines a global variable or class field called `num`, then your code will suddenly use it instead of creating a local variable. However, for casual programming it is offered as a convenience.)
+(UNDER CONSIDERATION) If `num` is not already defined, then this will create a new variable using the type of the initializer (integer in this case). Again, only the type of the first assignment matters, the type of later assignments are not taken into account. (This technique is not recommended for production code, because if someone later defines a global variable or class field called `num`, then your code will suddenly use it instead of creating a local variable. However, for casual programming it is offered as a convenience.)

 It's possible to declare a variable as `static`. In this case, the variable, and its value, is not destroyed before the program itself terminates. Example:

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Thu, 27 Feb 2014 07:04:37 -0000</pubDate><guid>https://sourceforge.netbb8c4ebe9f201a9863ec77f7d974a36ac47a6c39</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v38
+++ v39
@@ -168,7 +168,7 @@
          do_something(num);
     }

-Here, the parentheses are required. They contain three statement parts separated by semicolons. Each part is optional, but the semicolons are mandatory. The first part is a comma-separated initializer list, which can contain definitions of new variables and/or assignments to already existing variables. If a new variable is defined here, its scope is only the foor loop itself. The second part is a condition. As in a while loop, it is tested before the first iteration. The third part is a comma-separated list of assignments to perform after every iteration, just before testing the condition again.
+Here, the parentheses are required. They contain three statement parts separated by semicolons. Each part is optional, but the semicolons are mandatory. The first part is a comma-separated initializer list, which can contain definitions of new variables and/or assignments to already existing variables. If a new variable is defined here, its scope is only the for loop itself. The second part is a condition. As in a while loop, it is tested before the first iteration. The third part is a comma-separated list of assignments to perform after every iteration, just before testing the condition again.

 Control flow statements
 -----------------------
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Sun, 29 Dec 2013 06:21:50 -0000</pubDate><guid>https://sourceforge.neta93fb9f6ba3b91d31730425ca196d55b74edd0ef</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v37
+++ v38
@@ -247,7 +247,7 @@
         handle_any_error();
     }

-The above combines all of the described handlers. If an exception is thrown from `risky_operation`, then `finish_operation` is called anyway, followed by the appropriate exception handler. (However, exceptions thrown by `finish_operation` will not be handled by this try statement.)
+The above combines all of the described handlers. If an exception is thrown from `risky_operation`, then `finish_operation` is called anyway, after the appropriate exception handler. (However, exceptions thrown by `finish_operation` will not be handled by this try statement.)

 Goto statements
 ---------------
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Thu, 26 Dec 2013 21:11:30 -0000</pubDate><guid>https://sourceforge.netb2f5a6d178b4030212d8ca6de2d1ba61479e36ed</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v36
+++ v37
@@ -124,7 +124,7 @@
         printf("Found neither\n");
     }

-Unlike in C, there is no implicit fallthrough, so `break` statements are not needed (though they are allowed). This is because the majority of cases do not need it. (If you do need fallthrough functionality, you may use goto statements.)
+Unlike in C, there is no implicit fallthrough, so `break` statements are not needed (though they are allowed). This is because the majority of cases do not need fallthrough. (If you do need such functionality, you may use goto statements.)

 Each `case` is its own scope. There's no need for extra curly brackets if you need to define local variables inside a particular `case`.

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Thu, 26 Dec 2013 00:07:45 -0000</pubDate><guid>https://sourceforge.net759951ff1af2b3fc7c7592b0c88ffa3748f59599</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v35
+++ v36
@@ -108,97 +108,6 @@
 In such cases, however, you can usually add conditions to statements instead.

     num = 10 if num &lt; 10;
-
-While loops
------------
-The while loop allows statements to be executed repeatedly as long as a condition is true. The condition is tested before every loop iteration (but not during them). The standard way to write while loops is to use compound statements.
-
-    while num &lt; 10 {
-        num = num + 1;
-    }
-
-As with the if statement, compound statements are not mandatory. Some statements that start with a keyword are recognized (but not as many as for the if statement). Otherwise, you can use the `do` keyword.
-
-    while num &lt; 10 do num = num + 1;
-
-Do-while loops
---------------
-Do-while loops are like while loops, except that the condition is first tested after the first loop iteration, instead of before. This means that the statements are always executed at least once.
-
-    do {
-        num = num + 1;
-    } while num &lt; 10;
-
-Or, without compound statements:
-
-    do num = num + 1 while num &lt; 10;
-
-For loops
----------
-For loops come in a couple of variants. The simple one iterates over all elements in a container or range.
-
-    for x in the_list {
-        do_something(x);
-    }
-
-In this case, `the_list` is a variable referring to a container object holding a list of objects. The statements are executed once for each such object, with the local variable `x` referring to that object. The scope of the variable is only the for loop itself.
-
-The other variant is the C-style for loop.
-
-    for (num=0; num&lt;10; num+=1) {
-         do_something(num);
-    }
-
-Here, the parentheses are required. They contain three statement parts separated by semicolons. Each part is optional, but the semicolons are mandatory. The first part is a comma-separated initializer list, which can contain definitions of new variables and/or assignments to already existing variables. If a new variable is defined here, its scope is only the foor loop itself. The second part is a condition. As in a while loop, it is tested before the first iteration. The third part is a comma-separated list of assignments to perform after every iteration, just before testing the condition again.
-
-Control flow statements
------------------------
-The `break` statement breaks out of a loop or switch statement. Example:
-
-    do {
-        if need_to_abort() {
-            break;
-        }
-        num = num + 1;
-    } while num &lt; 10;
-
-The `continue` statement breaks out of the current iteration of a loop, but not the loop itself. The next iteration is prepared as normal (including any for-loop assignments, and testing of any loop condition). Example:
-
-    do {
-        if need_to_try_again() {
-            continue;
-        }
-        num = num + 1;
-    } while num &lt; 10;
-
-The `return` statement ends execution of a function and returns the provided value, if any. Example:
-
-    return num;
-
-As with assignments, conditions can be added to control flow statements.
-
-Goto statements
----------------
-(NOT IMPLEMENTED YET)
-
-Goto statements can be used to cause execution to jump directly to some given point inside a function. They are subject to several restrictions. For example, you are, in general, not allowed to jump directly into a scope you're not already in. Most of the time, goto statements should be avoided in favour of other language features (like control flow statements, or exceptions and try statements), but sometimes they are useful.
-
-Goto statements come in a couple of variants. The regular one requires that you explicitly declare jump targets using `label`:
-
-    label my_label;
-    num = num + 1;
-
-    goto my_label;
-
-There's also a variant that can be used inside switch statements:
-
-    switch num {
-    case 5:
-        printf("Handle 5\n");
-        goto case 6;
-    case 6:
-        printf("Handle 5 or 6\n");
-    }

 Switch statements
 -----------------
@@ -219,6 +128,74 @@

 Each `case` is its own scope. There's no need for extra curly brackets if you need to define local variables inside a particular `case`.

+While loops
+-----------
+The while loop allows statements to be executed repeatedly as long as a condition is true. The condition is tested before every loop iteration (but not during them). The standard way to write while loops is to use compound statements.
+
+    while num &lt; 10 {
+        num = num + 1;
+    }
+
+As with the if statement, compound statements are not mandatory. Some statements that start with a keyword are recognized (but not as many as for the if statement). Otherwise, you can use the `do` keyword.
+
+    while num &lt; 10 do num = num + 1;
+
+Do-while loops
+--------------
+Do-while loops are like while loops, except that the condition is first tested after the first loop iteration, instead of before. This means that the statements are always executed at least once.
+
+    do {
+        num = num + 1;
+    } while num &lt; 10;
+
+Or, without compound statements:
+
+    do num = num + 1 while num &lt; 10;
+
+For loops
+---------
+For loops come in a couple of variants. The simple one iterates over all elements in a container or range.
+
+    for x in the_list {
+        do_something(x);
+    }
+
+In this case, `the_list` is a variable referring to a container object holding a list of objects. The statements are executed once for each such object, with the local variable `x` referring to that object. The scope of the variable is only the for loop itself.
+
+The other variant is the C-style for loop.
+
+    for (num=0; num&lt;10; num+=1) {
+         do_something(num);
+    }
+
+Here, the parentheses are required. They contain three statement parts separated by semicolons. Each part is optional, but the semicolons are mandatory. The first part is a comma-separated initializer list, which can contain definitions of new variables and/or assignments to already existing variables. If a new variable is defined here, its scope is only the foor loop itself. The second part is a condition. As in a while loop, it is tested before the first iteration. The third part is a comma-separated list of assignments to perform after every iteration, just before testing the condition again.
+
+Control flow statements
+-----------------------
+The `break` statement breaks out of a loop or switch statement. Example:
+
+    do {
+        if need_to_abort() {
+            break;
+        }
+        num = num + 1;
+    } while num &lt; 10;
+
+The `continue` statement breaks out of the current iteration of a loop, but not the loop itself. The next iteration is prepared as normal (including any for-loop assignments, and testing of any loop condition). Example:
+
+    do {
+        if need_to_try_again() {
+            continue;
+        }
+        num = num + 1;
+    } while num &lt; 10;
+
+The `return` statement ends execution of a function and returns the provided value, if any. Example:
+
+    return num;
+
+As with assignments, conditions can be added to control flow statements.
+
 Try statements
 --------------
 Try statements are used to recover from exceptions. Exceptions are usually thrown when some error occurs. When exceptions are thrown, normal execution aborts. If the exception was thrown in scope of a try statement which has an exception handler that matches the exception, then execution jumps to that handler.
@@ -271,3 +248,26 @@
     }

 The above combines all of the described handlers. If an exception is thrown from `risky_operation`, then `finish_operation` is called anyway, followed by the appropriate exception handler. (However, exceptions thrown by `finish_operation` will not be handled by this try statement.)
+
+Goto statements
+---------------
+(NOT IMPLEMENTED YET)
+
+Goto statements can be used to cause execution to jump directly to some given point inside a function. They are subject to several restrictions. For example, you are, in general, not allowed to jump directly into a scope you're not already in. Most of the time, goto statements should be avoided in favour of other language features (like control flow statements, or exceptions and try statements), but sometimes they are useful.
+
+Goto statements come in a couple of variants. The regular one requires that you explicitly declare jump targets using `label`:
+
+    label my_label;
+    num = num + 1;
+
+    goto my_label;
+
+There's also a variant that can be used inside switch statements:
+
+    switch num {
+    case 5:
+        printf("Handle 5\n");
+        goto case 6;
+    case 6:
+        printf("Handle 5 or 6\n");
+    }
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Thu, 26 Dec 2013 00:04:25 -0000</pubDate><guid>https://sourceforge.net1d9a4d8df8813d12c67d2fd5b039b394f3431fac</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v34
+++ v35
@@ -192,7 +192,7 @@

 There's also a variant that can be used inside switch statements:

-    switch (num) {
+    switch num {
     case 5:
         printf("Handle 5\n");
         goto case 6;
@@ -226,7 +226,7 @@
     try {
         risky_operation();
         finish_operation();
-    } catch (err: IOError) {
+    } catch err: IOError {
         handle_io_error(err);
     }

@@ -244,7 +244,7 @@
     try {
         risky_operation();
         finish_operation();
-    } catch (err: IOError) {
+    } catch err: IOError {
         handle_io_error(err);
     } catch {
         handle_any_error();
@@ -264,7 +264,7 @@
         risky_operation();
     } finally {
         finish_operation();
-    } catch (err: IOError) {
+    } catch err: IOError {
         handle_io_error(err);
     } catch {
         handle_any_error();
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Wed, 25 Dec 2013 23:59:03 -0000</pubDate><guid>https://sourceforge.net5e931bebabe7d1de56cef7f4aeac52a59d349b88</guid></item><item><title>Syntax-Statements modified by Ove Kåven</title><link>https://sourceforge.net/p/mortal/wiki/Syntax-Statements/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v33
+++ v34
@@ -202,15 +202,15 @@

 Switch statements
 -----------------
-Switch statements allow statements to be executed depending on the value of a variable or expression. Unlike if statements, switch statements can have more than two branches. Although switch statements could be emulated using if chains, switch statements are usually more efficient.
-
-    switch (num) {
+Switch statements allow statements to be executed depending on the value of a variable or expression. While an if statement can only check one value at a time, a switch statement can check many. Thus, though switch statements could be emulated using if chains, switch statements are usually both more efficient and more readable.
+
+    switch num {
     case 5:
         printf("Found a 5\n");
     case 6:
         printf("Found a 6\n");
     case 10, 20:
-        printf("Found a 10 or 20\n);
+        printf("Found a 10 or 20\n");
     default:
         printf("Found neither\n");
     }
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ove Kåven</dc:creator><pubDate>Wed, 25 Dec 2013 23:57:48 -0000</pubDate><guid>https://sourceforge.net05e8b19754c6e4d900940d18ed6479ce2d6f73e8</guid></item></channel></rss>