diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 16 | ||||
-rw-r--r-- | docs/style-guide.rst | 11 | ||||
-rw-r--r-- | docs/types.rst | 2 | ||||
-rw-r--r-- | docs/units-and-global-variables.rst | 2 |
4 files changed, 20 insertions, 11 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index c94f8d99..e7b71c3d 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -355,7 +355,7 @@ functions matches the given function identifier (or if no data was supplied at all). Furthermore, this function is executed whenever the contract receives plain -Ether (witout data). In such a context, there is very little gas available to +Ether (without data). In such a context, there is very little gas available to the function call, so it is important to make fallback functions as cheap as possible. @@ -742,10 +742,10 @@ only once at a specific address and their code is reused using the ``DELEGATECAL (``CALLCODE`` until Homestead) feature of the EVM. This means that if library functions are called, their code is executed in the context of the calling contract, i.e. ``this`` points to the -calling contract and especially the storage from the calling contract can be +calling contract, and especially the storage from the calling contract can be accessed. As a library is an isolated piece of source code, it can only access state variables of the calling contract if they are explicitly supplied (it -would have to way to name them, otherwise). +would have no way to name them, otherwise). Libraries can be seen as implicit base contracts of the contracts that use them. They will not be explicitly visible in the inheritance hierarchy, but calls @@ -883,8 +883,8 @@ custom types without the overhead of external function calls: using BigInt for BigInt.bigint; function f() { - var x = bigint.fromUint(7); - var y = bigint.fromUint(uint(-1)); + var x = BigInt.fromUint(7); + var y = BigInt.fromUint(uint(-1)); var z = x.add(y); } } @@ -986,7 +986,7 @@ Let us rewrite the set example from the It is also possible to extend elementary types in that way:: library Search { - function indexOf(uint[] storage self, uint value) { + function indexOf(uint[] storage self, uint value) returns (uint) { for (uint i = 0; i < self.length; i++) if (self[i] == value) return i; return uint(-1); @@ -1004,8 +1004,8 @@ It is also possible to extend elementary types in that way:: function replace(uint _old, uint _new) { // This performs the library function call - uint index = data.find(_old); - if (index == -1) + uint index = data.indexOf(_old); + if (index == uint(-1)) data.push(_new); else data[index] = _new; diff --git a/docs/style-guide.rst b/docs/style-guide.rst index b9f06012..99db8147 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -155,7 +155,7 @@ Whitespace in Expressions Avoid extraneous whitespace in the following situations: -Immediately inside parenthesis, brackets or braces. +Immediately inside parenthesis, brackets or braces, with the exception of single-line function declarations. Yes:: @@ -165,6 +165,10 @@ No:: spam( ham[ 1 ], Coin( { name: "ham" } ) ); +Exception:: + + function singleLine() { spam(); } + Immediately before a comma, semicolon: Yes:: @@ -482,6 +486,11 @@ No:: } } +When declaring short functions with a single statement, it is permissible to do it on a single line. + +Permissible:: + + function shortFunction() { doSomething(); } These guidelines for function declarations are intended to improve readability. Authors should use their best judgement as this guide does not try to cover all diff --git a/docs/types.rst b/docs/types.rst index 515c200f..dbbd84d3 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -340,7 +340,7 @@ So ``bytes`` should always be preferred over ``byte[]`` because it is cheaper. .. note:: If you want to access the byte-representation of a string ``s``, use - ``bytes(s).length / bytes(s)[7] = x';``. Keep in mind + ``bytes(s).length`` / ``bytes(s)[7] = 'x';``. Keep in mind that you are accessing the low-level bytes of the utf-8 representation, and not the individual characters! diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 167c694d..8b8f4daa 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -15,7 +15,7 @@ Time Units ========== Suffixes of ``seconds``, ``minutes``, ``hours``, ``days``, ``weeks`` and -`years` after literal numbers can be used to convert between units of time where seconds are the base +``years`` after literal numbers can be used to convert between units of time where seconds are the base unit and units are considered naively in the following way: * ``1 == 1 second`` |