diff options
author | Rory O’Kane <rory@roryokane.com> | 2020-03-25 14:42:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 19:42:34 +0100 |
commit | 84b378b94fffed6e4e32cfebdd940a80425226d2 (patch) | |
tree | 9c1b45fdeb116ec913ebb30c368ff65243a99b53 | |
parent | 5b55aa52d05ff911d64febc973bed1f0c2d97d25 (diff) | |
download | Nim-84b378b94fffed6e4e32cfebdd940a80425226d2.tar.gz |
docs: say that `nil` can be used as a value (#13756)
and improve wording in other ways Showing that `nil` can be assigned helps to warn readers that variables can be `nil` even after being assigned a value.
-rw-r--r-- | doc/manual.rst | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/doc/manual.rst b/doc/manual.rst index 3a0faed2e..bffb9e60c 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -1767,12 +1767,15 @@ further information. Nil --- -If a reference points to *nothing*, it has the value ``nil``. ``nil`` is also -the default value for all ``ref`` and ``ptr`` types. Dereferencing ``nil`` -is an unrecoverable fatal runtime error (and not a panic). -A dereferencing operation ``p[]`` implies that ``p`` is not nil. This can be -exploited by the implementation to optimize code like: +If a reference points to *nothing*, it has the value ``nil``. ``nil`` is the +default value for all ``ref`` and ``ptr`` types. The ``nil`` value can also be +used like any other literal value. For example, it can be used in an assignment +like ``myRef = nil``. +Dereferencing ``nil`` is an unrecoverable fatal runtime error (and not a panic). + +A successful dereferencing operation ``p[]`` implies that ``p`` is not nil. This +can be exploited by the implementation to optimize code like: .. code-block:: nim |