diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/control-structures.rst | 39 | ||||
-rw-r--r-- | docs/index.rst | 3 |
2 files changed, 41 insertions, 1 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 220cbb42..d2ad0936 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -10,7 +10,7 @@ Control Structures Most of the control structures from C/JavaScript are available in Solidity except for ``switch`` and ``goto``. So there is: ``if``, ``else``, ``while``, ``for``, ``break``, ``continue``, ``return``, ``? :``, with -the usual semantics known from C / JavaScript. +the usual semantics known from C or JavaScript. Parentheses can *not* be omitted for conditionals, but curly brances can be omitted around single-statement bodies. @@ -113,6 +113,43 @@ Also, the names of unused parameters (especially return parameters) can be omitt } +.. index:: ! new, contracts;creating + +.. _creating-contracts: + +Creating Contracts via new +========================== + +A contract can create a new contract using the ``new`` keyword. The full +code of the contract to be created has to be known and thus recursive +creation-dependencies are now possible. + +:: + + contract D { + uint x; + function D(uint a) { + x = a; + } + } + contract C { + D d = new D(4); // will be executed as part of C's constructor + + function createD(uint arg) { + D newD = new D(arg); + } + + function createAndEndowD(uint arg, uint amount) { + // Send ether along with the creation + D newD = (new D).value(amount)(arg); + } + } + +As seen in the example, it is possible to forward Ether to the creation, +but it is not possible to limit the amount of gas. If the creation fails +(due to out-of-stack, not enough balance or other problems), an exception +is thrown. + Order of Evaluation of Expressions ================================== diff --git a/docs/index.rst b/docs/index.rst index 5ca5c4a9..4b3ace89 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -56,6 +56,9 @@ Available Solidity Integrations * `Vim Solidity <https://github.com/tomlion/vim-solidity/>`_ Plugin for the Vim editor providing syntax highlighting. +* `Vim Syntastic <https://github.com/scrooloose/syntastic>`_ + Plugin for the Vim editor providing compile checking. + Discontinued: * `Mix IDE <https://github.com/ethereum/mix/>`_ |