From 37319592f8da67ee500442407a8481c2246fb373 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Mon, 30 May 2022 18:37:14 +0200
Subject: [PATCH] Add break and continue doc

---
 doc/userdoc.org | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/doc/userdoc.org b/doc/userdoc.org
index 4d8c90f29..3f8ae8f9c 100644
--- a/doc/userdoc.org
+++ b/doc/userdoc.org
@@ -2005,6 +2005,48 @@ The result is
 #+results: while-block
 
 
+*** ~break~ and ~continue~ keywords.
+
+These *keywords* are used to control loops behavior from enclosed loop
+statements. They follow their ~C++~ counterparts.
+
+- The ~continue~ keyword is used to skip the instructions that follow in
+  the loop statement and continue the loop.
+
+- The ~break~ keyword is leaves the current loop.
+
+An example of use of the ~continue~ keyword is
+#+NAME: nested-continue
+#+BEGIN_SRC pugs :exports both :results output
+  for (let i:N, i = 0; i < 5; ++i) {
+    cout << i << ": ";
+    for (let j:N, j=0; j < 5; ++j) {
+      if (j<i) continue;
+      cout << j << " ";
+    }
+    cout << "\n";
+  }
+#+END_SRC
+The result is
+#+results: nested-continue
+
+Replacing the ~continue~ keyword by a ~break~
+#+NAME: nested-break
+#+BEGIN_SRC pugs :exports both :results output
+  for (let i:N, i = 0; i < 5; ++i) {
+    cout << i << ": ";
+    for (let j:N, j=0; j < 5; ++j) {
+      if (j>i) break;
+      cout << j << " ";
+    }
+    cout << "\n";
+  }
+#+END_SRC
+changes the output to
+#+results: nested-break
+
+Obviously the behavior is the same using ~do...while~ or ~while~ loops.
+
 ** TODO Functions<<functions>>
 
 *** Pure functions
-- 
GitLab