Merge pull request #2492 from 0x5e5e/patch-1

Update types.srt
This commit is contained in:
chriseth 2017-06-30 17:10:19 +02:00 committed by GitHub
commit 568e752076

View File

@ -54,13 +54,13 @@ Operators:
* Bit operators: ``&``, ``|``, ``^`` (bitwise exclusive or), ``~`` (bitwise negation) * Bit operators: ``&``, ``|``, ``^`` (bitwise exclusive or), ``~`` (bitwise negation)
* Arithmetic operators: ``+``, ``-``, unary ``-``, unary ``+``, ``*``, ``/``, ``%`` (remainder), ``**`` (exponentiation), ``<<`` (left shift), ``>>`` (right shift) * Arithmetic operators: ``+``, ``-``, unary ``-``, unary ``+``, ``*``, ``/``, ``%`` (remainder), ``**`` (exponentiation), ``<<`` (left shift), ``>>`` (right shift)
Division always truncates (it just is compiled to the DIV opcode of the EVM), but it does not truncate if both Division always truncates (it is just compiled to the DIV opcode of the EVM), but it does not truncate if both
operators are :ref:`literals<rational_literals>` (or literal expressions). operators are :ref:`literals<rational_literals>` (or literal expressions).
Division by zero and modulus with zero throws a runtime exception. Division by zero and modulus with zero throws a runtime exception.
The result of a shift operation is the type of the left operand. The The result of a shift operation is the type of the left operand. The
expression ``x << y`` is equivalent to ``x * 2**y`` and ``x >> y`` is expression ``x << y`` is equivalent to ``x * 2**y``, and ``x >> y`` is
equivalent to ``x / 2**y``. This means that shifting negative numbers equivalent to ``x / 2**y``. This means that shifting negative numbers
sign extends. Shifting by a negative amount throws a runtime exception. sign extends. Shifting by a negative amount throws a runtime exception.
@ -77,7 +77,7 @@ sign extends. Shifting by a negative amount throws a runtime exception.
Address Address
------- -------
``address``: Holds a 20 byte value (size of an Ethereum address). Address types also have members and serve as base for all contracts. ``address``: Holds a 20 byte value (size of an Ethereum address). Address types also have members and serve as a base for all contracts.
Operators: Operators:
@ -125,7 +125,7 @@ the function ``call`` is provided which takes an arbitrary number of arguments o
``call`` returns a boolean indicating whether the invoked function terminated (``true``) or caused an EVM exception (``false``). It is not possible to access the actual data returned (for this we would need to know the encoding and size in advance). ``call`` returns a boolean indicating whether the invoked function terminated (``true``) or caused an EVM exception (``false``). It is not possible to access the actual data returned (for this we would need to know the encoding and size in advance).
In a similar way, the function ``delegatecall`` can be used: The difference is that only the code of the given address is used, all other aspects (storage, balance, ...) are taken from the current contract. The purpose of ``delegatecall`` is to use library code which is stored in another contract. The user has to ensure that the layout of storage in both contracts is suitable for delegatecall to be used. Prior to homestead, only a limited variant called ``callcode`` was available that did not provide access to the original ``msg.sender`` and ``msg.value`` values. In a similar way, the function ``delegatecall`` can be used: the difference is that only the code of the given address is used, all other aspects (storage, balance, ...) are taken from the current contract. The purpose of ``delegatecall`` is to use library code which is stored in another contract. The user has to ensure that the layout of storage in both contracts is suitable for delegatecall to be used. Prior to homestead, only a limited variant called ``callcode`` was available that did not provide access to the original ``msg.sender`` and ``msg.value`` values.
All three functions ``call``, ``delegatecall`` and ``callcode`` are very low-level functions and should only be used as a *last resort* as they break the type-safety of Solidity. All three functions ``call``, ``delegatecall`` and ``callcode`` are very low-level functions and should only be used as a *last resort* as they break the type-safety of Solidity.
@ -472,19 +472,19 @@ context, there is always a default, but it can be overridden by appending
either ``storage`` or ``memory`` to the type. The default for function parameters (including return parameters) is ``memory``, the default for local variables is ``storage`` and the location is forced either ``storage`` or ``memory`` to the type. The default for function parameters (including return parameters) is ``memory``, the default for local variables is ``storage`` and the location is forced
to ``storage`` for state variables (obviously). to ``storage`` for state variables (obviously).
There is also a third data location, "calldata", which is a non-modifyable There is also a third data location, "calldata", which is a non-modifiable,
non-persistent area where function arguments are stored. Function parameters non-persistent area where function arguments are stored. Function parameters
(not return parameters) of external functions are forced to "calldata" and (not return parameters) of external functions are forced to "calldata" and
it behaves mostly like memory. behave mostly like memory.
Data locations are important because they change how assignments behave: Data locations are important because they change how assignments behave:
Assignments between storage and memory and also to a state variable (even from other state variables) assignments between storage and memory and also to a state variable (even from other state variables)
always create an independent copy. always create an independent copy.
Assignments to local storage variables only assign a reference though, and Assignments to local storage variables only assign a reference though, and
this reference always points to the state variable even if the latter is changed this reference always points to the state variable even if the latter is changed
in the meantime. in the meantime.
On the other hand, assignments from a memory stored reference type to another On the other hand, assignments from a memory stored reference type to another
memory-stored reference type does not create a copy. memory-stored reference type do not create a copy.
:: ::