From 679ea2820fd6bb76ddd294101ef548bab6cd6425 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 19 Oct 2016 18:43:07 +0200 Subject: Part of the documentation. --- docs/types.rst | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'docs/types.rst') diff --git a/docs/types.rst b/docs/types.rst index 9ec9e526..2e1cbee9 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -234,7 +234,7 @@ Hexademical Literals behave like String Literals and have the same convertibilit .. _enums: Enums -===== +----- Enums are one way to create a user-defined type in Solidity. They are explicitly convertible to and from all integer types but implicit conversion is not allowed. The explicit conversions @@ -267,6 +267,46 @@ check the value ranges at runtime and a failure causes an exception. Enums need } } +.. index:: ! function type, ! type; function + +.. _function_types: + +Function Types +-------------- + +Functions can be assigned to variables and passed on together with function calls. +These types come in two flavours: *internal* and *external* functions. + +Internal functions can only be used inside the current contract (more specifically, +inside the current code unit, which also includes internal library functions) +because they cannot be executed outside of the +context of the current function. Calling an internal function is realized +by jumping to its entry label, just like when calling an function of the current +contract internally. + +External functions consist of an address and a function signature and they can +be passed via and returned from external function calls. + +Function types are notated as follows: + + function () internal / external returns () + +As always, the ``returns ()`` is optional. + +By default, function types are internal, so the ``internal`` keyword can be +omitted. + +If a function type variable is not initialized, calling it will result +in an exception. + +If external function types are used outside of the context of Solidity, +they are converted into the ``bytes24`` type. + +Example usage: + + library ArrayUtils { + + .. index:: ! type;reference, ! reference type, storage, memory, location, array, struct Reference Types -- cgit v1.2.3