diff options
author | Araq <rumpf_a@web.de> | 2011-09-24 13:55:24 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-09-24 13:55:24 +0200 |
commit | 72ceda98cbbef896c31102a2c90d5f9fe1033d03 (patch) | |
tree | e8d5ba9d5602c6a1455c17da85dbf05b86ca02d7 /doc/manual.txt | |
parent | 033e3dfc50349ffeb5f9d9e839bd62fa22113b69 (diff) | |
download | Nim-72ceda98cbbef896c31102a2c90d5f9fe1033d03.tar.gz |
implemented optional pragma for implicit discard
Diffstat (limited to 'doc/manual.txt')
-rwxr-xr-x | doc/manual.txt | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/doc/manual.txt b/doc/manual.txt index 122668dfb..55a008632 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -1474,14 +1474,26 @@ Syntax:: Example: .. code-block:: nimrod + proc p(x, y: int): int {.optional.} = + return x + y - discard proc_call("arg1", "arg2") # discard the return value of `proc_call` + discard p(3, 4) # discard the return value of `p` The `discard`:idx: statement evaluates its expression for side-effects and -throws the expression's resulting value away. If the expression has no -side-effects, this generates a static error. Ignoring the return value of a -procedure without using a discard statement is a static error too. - +throws the expression's resulting value away. + +Ignoring the return value of a procedure without using a discard statement is +a static error. + +The return value can be ignored implicitely if the called proc/iterator has +been declared with the `optional`:idx: pragma: + +.. code-block:: nimrod + proc p(x, y: int): int {.optional.} = + return x + y + + p(3, 4) # now valid + Var statement ~~~~~~~~~~~~~ |