mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Documentation.
This commit is contained in:
parent
33450619b1
commit
add55fd793
@ -1,6 +1,7 @@
|
|||||||
### 0.6.9 (unreleased)
|
### 0.6.9 (unreleased)
|
||||||
|
|
||||||
Language Features:
|
Language Features:
|
||||||
|
* Permit calldata location for all variables.
|
||||||
|
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
|
@ -13,8 +13,7 @@ arrays and mappings. If you use a reference type, you always have to explicitly
|
|||||||
provide the data area where the type is stored: ``memory`` (whose lifetime is limited
|
provide the data area where the type is stored: ``memory`` (whose lifetime is limited
|
||||||
to an external function call), ``storage`` (the location where the state variables
|
to an external function call), ``storage`` (the location where the state variables
|
||||||
are stored, where the lifetime is limited to the lifetime of a contract)
|
are stored, where the lifetime is limited to the lifetime of a contract)
|
||||||
or ``calldata`` (special data location that contains the function arguments,
|
or ``calldata`` (special data location that contains the function arguments).
|
||||||
only available for external function call parameters).
|
|
||||||
|
|
||||||
An assignment or type conversion that changes the data location will always incur an automatic copy operation,
|
An assignment or type conversion that changes the data location will always incur an automatic copy operation,
|
||||||
while assignments inside the same data location only copy in some cases for storage types.
|
while assignments inside the same data location only copy in some cases for storage types.
|
||||||
@ -26,9 +25,9 @@ Data location
|
|||||||
|
|
||||||
Every reference type has an additional
|
Every reference type has an additional
|
||||||
annotation, the "data location", about where it is stored. There are three data locations:
|
annotation, the "data location", about where it is stored. There are three data locations:
|
||||||
``memory``, ``storage`` and ``calldata``. Calldata is only valid for parameters of external contract
|
``memory``, ``storage`` and ``calldata``. Calldata is a non-modifiable,
|
||||||
functions and is required for this type of parameter. Calldata is a non-modifiable,
|
|
||||||
non-persistent area where function arguments are stored, and behaves mostly like memory.
|
non-persistent area where function arguments are stored, and behaves mostly like memory.
|
||||||
|
It is required for parameters of external functions but can also be used for other variables.
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@ -36,6 +35,12 @@ non-persistent area where function arguments are stored, and behaves mostly like
|
|||||||
depending on the kind of variable, function type, etc., but all complex types must now give an explicit
|
depending on the kind of variable, function type, etc., but all complex types must now give an explicit
|
||||||
data location.
|
data location.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If you can, try to use ``calldata`` as data location because it will avoid copies and
|
||||||
|
also makes sure that the data cannot be modified. Arrays and structs with ``calldata``
|
||||||
|
data location can also be returned from functions, but it is not possible to
|
||||||
|
allocate such types.
|
||||||
|
|
||||||
.. _data-location-assignment:
|
.. _data-location-assignment:
|
||||||
|
|
||||||
Data location and assignment behaviour
|
Data location and assignment behaviour
|
||||||
|
Loading…
Reference in New Issue
Block a user