summary refs log tree commit diff stats
path: root/doc/manual.txt
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-09-24 13:55:24 +0200
committerAraq <rumpf_a@web.de>2011-09-24 13:55:24 +0200
commit72ceda98cbbef896c31102a2c90d5f9fe1033d03 (patch)
treee8d5ba9d5602c6a1455c17da85dbf05b86ca02d7 /doc/manual.txt
parent033e3dfc50349ffeb5f9d9e839bd62fa22113b69 (diff)
downloadNim-72ceda98cbbef896c31102a2c90d5f9fe1033d03.tar.gz
implemented optional pragma for implicit discard
Diffstat (limited to 'doc/manual.txt')
-rwxr-xr-xdoc/manual.txt22
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

 ~~~~~~~~~~~~~

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287