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)
|
||||
|
||||
Language Features:
|
||||
* Permit calldata location for all variables.
|
||||
|
||||
|
||||
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
|
||||
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)
|
||||
or ``calldata`` (special data location that contains the function arguments,
|
||||
only available for external function call parameters).
|
||||
or ``calldata`` (special data location that contains the function arguments).
|
||||
|
||||
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.
|
||||
@ -26,9 +25,9 @@ Data location
|
||||
|
||||
Every reference type has an additional
|
||||
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
|
||||
functions and is required for this type of parameter. Calldata is a non-modifiable,
|
||||
``memory``, ``storage`` and ``calldata``. Calldata is a non-modifiable,
|
||||
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::
|
||||
@ -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
|
||||
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 and assignment behaviour
|
||||
|
Loading…
Reference in New Issue
Block a user