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.
This commit is contained in:
Rory O’Kane 2020-03-25 14:42:34 -04:00 • committed by GitHub
commit 84b378b94f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1767,12 +1767,15 @@ further information.
Nil Nil
--- ---
If a reference points to *nothing*, it has the value ``nil``. ``nil`` is also If a reference points to *nothing*, it has the value ``nil``. ``nil`` is the
the default value for all ``ref`` and ``ptr`` types. Dereferencing ``nil`` default value for all ``ref`` and ``ptr`` types. The ``nil`` value can also be
is an unrecoverable fatal runtime error (and not a panic). used like any other literal value. For example, it can be used in an assignment
A dereferencing operation ``p[]`` implies that ``p`` is not nil. This can be like ``myRef = nil``.
exploited by the implementation to optimize code like:
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 .. code-block:: nim