summary refs log tree commit diff stats
path: root/doc/manual
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-09-10 13:18:11 +0200
committerAraq <rumpf_a@web.de>2015-09-12 11:07:46 +0200
commit3959a59e57d43a41b5ff6929875d53c46fd8f78a (patch)
tree4d8efa8f6eaa09dc3252e13f679277c9e0b0a330 /doc/manual
parentac6b21a018cc5873a8ec5011bbc0068989e12259 (diff)
downloadNim-3959a59e57d43a41b5ff6929875d53c46fd8f78a.tar.gz
documented void context
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/stmts.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/manual/stmts.txt b/doc/manual/stmts.txt
index 062c08d7c..a833d7b7d 100644
--- a/doc/manual/stmts.txt
+++ b/doc/manual/stmts.txt
@@ -60,6 +60,24 @@ An empty ``discard`` statement is often used as a null statement:
     else: discard
 
 
+Void context
+------------
+
+In a list of statements every expression except the last one needs to have the
+type ``void``. In addition to this rule an assignment to the builtin ``result``
+symbol also triggers a ``void`` context:
+
+.. code-block:: nim
+  proc invalid*(): string =
+    result = "foo"
+    "invalid"  # Error: value of type 'string' has to be discarded
+
+.. code-block:: nim
+  proc valid*(): string =
+    let x = 317
+    "valid"
+
+
 Var statement
 -------------