diff options
author | Araq <rumpf_a@web.de> | 2014-12-12 14:52:06 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-12-12 14:52:06 +0100 |
commit | 752e920b58d537b8e871e8711551a1267a7bbb5f (patch) | |
tree | c86681f315bc894b49ef35f43224e9c192e62c3c | |
parent | 5a52e941b5a5e6fa92b76608dc8ed599821cd6c8 (diff) | |
download | Nim-752e920b58d537b8e871e8711551a1267a7bbb5f.tar.gz |
documented converters
-rw-r--r-- | doc/manual/procs.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/manual/procs.txt b/doc/manual/procs.txt index d048615eb..a4e0e0bda 100644 --- a/doc/manual/procs.txt +++ b/doc/manual/procs.txt @@ -584,3 +584,23 @@ parameters of an outer factory proc: a for loop, the compiler will implicity use the ``auto`` return type if no type is given by the user. In contrast, since closure iterators can be used as a collaborative tasking system, ``void`` is a valid return type for them. + + +Converters +========== + +A converter is like an ordinary proc except that it enhances +the "implicitly convertible" type relation (see `Convertible relation`_): + +.. code-block:: nim + # bad style ahead: Nim is not C. + converter toBool(x: int): bool = x != 0 + + if 4: + echo "compiles" + + +A converter can also be explicitly invoked for improved readability. Note that +implicit converter chaining is not supported: If there is a converter from +type A to type B and from type B to type C the implicit conversion from A to C +is not provided. |