docs: Clarify the difference between denominations and literal suffixes

This commit is contained in:
Kamil Śliwak 2023-04-14 16:34:48 +02:00
parent edcc3af9c8
commit a15881092c
2 changed files with 21 additions and 2 deletions

View File

@ -196,6 +196,7 @@ can still return a value to the caller by use of the ``return`` statement.
}
.. index:: ! literal suffix; suffix call syntax
.. _function-calls-suffix-calls:
Suffix Calls
------------
@ -231,6 +232,15 @@ first in order to obtain the two input values.
See the section on :ref:`calling suffix functions<calling_suffix_functions>` for more information
on the limitations of this call syntax.
.. note::
Suffix calls should not be confused with the application of :ref:`denomination suffixes<denominations>`,
which use the same syntax, but simply modify the literal without an actual function call.
There is only a limited number of denominations and their names cannot be used for literal
suffixes.
The only exceptions are ``finney`` and ``szabo``, which used to be denominations, but were
deprecated, and are now usable as identifiers.
.. index:: ! new, contracts;creating

View File

@ -5,12 +5,21 @@
Units and Globally Available Variables
**************************************
Solidity defines several *denominations*, which can be applied as suffixes to
:ref:`rational number literals<rational_literals>` to modify the value while still keeping it a literal.
.. note::
Denominations should not be confused with :ref:`literal suffixes<literal_suffixes>`, which use
the same syntax, but can be defined by the user and result in a
:ref:`function call<function-calls-suffix-calls>`.
.. index:: ! wei, ! finney, ! szabo, ! gwei, ! ether, ! denomination;ether
Ether Units
===========
A literal number can take a suffix of ``wei``, ``gwei`` or ``ether`` to specify a subdenomination of Ether, where Ether numbers without a postfix are assumed to be Wei.
A literal number can take a suffix of ``wei``, ``gwei`` or ``ether`` to specify a sub-denomination of
Ether, where Ether numbers without a postfix are assumed to be Wei.
.. code-block:: solidity
:force:
@ -19,7 +28,7 @@ A literal number can take a suffix of ``wei``, ``gwei`` or ``ether`` to specify
assert(1 gwei == 1e9);
assert(1 ether == 1e18);
The only effect of the subdenomination suffix is a multiplication by a power of ten.
The only effect of the sub-denomination suffix is a multiplication by a power of ten.
.. note::
The denominations ``finney`` and ``szabo`` have been removed in version 0.7.0.