aboutsummaryrefslogtreecommitdiffstats
path: root/docs/types.rst
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-15 03:38:07 +0800
committerGitHub <noreply@github.com>2018-08-15 03:38:07 +0800
commitcc54f6c4256cdccf4b25586ed63800caa836d9c6 (patch)
tree11fe607f1acbc6daaa8d17b30ac45db2f7981d77 /docs/types.rst
parent8f27fb1f4a14f369e8feb3ea22a38d50998cad5c (diff)
parent14e116c1d57e1797e7206299d0fdfed2aa03cdf2 (diff)
downloaddexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.tar
dexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.tar.gz
dexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.tar.bz2
dexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.tar.lz
dexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.tar.xz
dexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.tar.zst
dexon-solidity-cc54f6c4256cdccf4b25586ed63800caa836d9c6.zip
Merge pull request #4738 from ethereum/dataloc_merged
Enforce data location.
Diffstat (limited to 'docs/types.rst')
-rw-r--r--docs/types.rst22
1 files changed, 10 insertions, 12 deletions
diff --git a/docs/types.rst b/docs/types.rst
index 18400dee..0e0f4b13 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -580,16 +580,18 @@ variables are held).
Data location
-------------
+
Every complex type, i.e. *arrays* and *structs*, has an additional
-annotation, the "data location", about whether it is stored in memory or in storage. Depending on the
-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
-to ``storage`` for state variables (obviously).
+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,
+non-persistent area where function arguments are stored, and behaves mostly like memory.
+
-There is also a third data location, ``calldata``, which is a non-modifiable,
-non-persistent area where function arguments are stored. Function parameters
-(not return parameters) of external functions are forced to ``calldata`` and
-behave mostly like ``memory``.
+.. note::
+ Prior to version 0.5.0 the data location could be omitted, and would default to different locations
+ depending on the kind of variable, function type, etc., but all complex types must now give an explicit
+ data location.
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)
@@ -635,10 +637,6 @@ Forced data location:
- parameters (not return) of external functions: calldata
- state variables: storage
-Default data location:
- - parameters (also return) of functions: memory
- - all other local variables: storage
-
.. index:: ! array
.. _arrays: