From 84b378b94fffed6e4e32cfebdd940a80425226d2 Mon Sep 17 00:00:00 2001 From: Rory O’Kane Date: Wed, 25 Mar 2020 14:42:34 -0400 Subject: 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. --- doc/manual.rst | 13 ++++++++----- 1 file 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 -- cgit 1.4.1-2-gfad0