This commit is contained in:
Araq 2014-12-24 13:02:58 +01:00
commit 2be3f501a1
6 changed files with 39 additions and 14 deletions

View file

@ -47,6 +47,27 @@ the rest of the procedure - that is not within a ``finally`` clause -
is not executed (if an exception occurs).
Try expression
--------------
Try can also be used as an expression; the type of the ``try`` branch then
needs to fit the types of ``except`` branches, but the type of the ``finally``
branch always has to be ``void``:
.. code-block:: nim
let x = try: parseInt("133a")
except: -1
finally: echo "hi"
To prevent confusing code there is a parsing limitation; if the ``try``
follows a ``(`` it has to be written as a one liner:
.. code-block:: nim
let x = (try: parseInt("133a") except: -1)
Defer statement
---------------