Skip to content

Commit 444103c

Browse files
committed
Split function type documentation into smaller sections
1 parent a28b2b1 commit 444103c

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

docs/types/value-types.rst

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ that has the same data representation as the input, whereas ``toUFixed256x18`` r
728728
Function Types
729729
--------------
730730

731-
Function types are the types of functions. Variables of function type
731+
Function types are the types of functions. Variables of a function type
732732
can be assigned from functions and function parameters of function type
733733
can be used to pass functions to and return functions from function calls.
734734
Function types come in two flavours - *internal* and *external* functions:
@@ -743,6 +743,20 @@ contract internally.
743743
External functions consist of an address and a function signature and they can
744744
be passed via and returned from external function calls.
745745

746+
Note that public functions of the current contract can be used both as an
747+
internal and as an external function. To use ``f`` as an internal function,
748+
just use ``f``, if you want to use its external form, use ``this.f``.
749+
750+
If a function type variable is not initialised, calling it results
751+
in a :ref:`Panic error<assert-and-require>`. The same happens if you call a function after using ``delete``
752+
on it.
753+
754+
.. note::
755+
Lambda or inline functions are planned but not yet supported.
756+
757+
Declaration syntax
758+
^^^^^^^^^^^^^^^^^^
759+
746760
Function types are notated as follows:
747761

748762
.. code-block:: solidity
@@ -759,7 +773,8 @@ omitted. Note that this only applies to function types. Visibility has
759773
to be specified explicitly for functions defined in contracts, they
760774
do not have a default.
761775

762-
Conversions:
776+
Conversions
777+
^^^^^^^^^^^
763778

764779
A function type ``A`` is implicitly convertible to a function type ``B`` if and only if
765780
their parameter types are identical, their return types are identical,
@@ -788,18 +803,10 @@ Which makes it possible to assign a ``payable`` function pointer to a ``non-paya
788803
function pointer ensuring both types behave the same way, i.e, both cannot be used
789804
to send ether.
790805

791-
If a function type variable is not initialised, calling it results
792-
in a :ref:`Panic error<assert-and-require>`. The same happens if you call a function after using ``delete``
793-
on it.
794-
795806
If external function types are used outside of the context of Solidity,
796807
they are treated as the ``function`` type, which encodes the address
797808
followed by the function identifier together in a single ``bytes24`` type.
798809

799-
Note that public functions of the current contract can be used both as an
800-
internal and as an external function. To use ``f`` as an internal function,
801-
just use ``f``, if you want to use its external form, use ``this.f``.
802-
803810
A function of an internal type can be assigned to a variable of an internal function type regardless
804811
of where it is defined.
805812
This includes private, internal and public functions of both contracts and libraries as well as free
@@ -828,7 +835,8 @@ Libraries are excluded because they require a ``delegatecall`` and use :ref:`a d
828835
convention for their selectors <library-selectors>`.
829836
Functions declared in interfaces do not have definitions so pointing at them does not make sense either.
830837

831-
Members:
838+
Members
839+
^^^^^^^
832840

833841
External (or public) functions have the following members:
834842

@@ -843,6 +851,9 @@ External (or public) functions have the following members:
843851
respectively. See :ref:`External Function Calls <external-function-calls>` for
844852
more information.
845853

854+
Examples
855+
^^^^^^^^
856+
846857
Example that shows how to use the members:
847858

848859
.. code-block:: solidity
@@ -966,6 +977,3 @@ Another example that uses external function types:
966977
exchangeRate = response;
967978
}
968979
}
969-
970-
.. note::
971-
Lambda or inline functions are planned but not yet supported.

0 commit comments

Comments
 (0)