diff options
author | chriseth <chris@ethereum.org> | 2018-08-07 21:10:42 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-08-15 00:07:15 +0800 |
commit | e3b6c5a4bdbc3066889b6898e5e07bfd599a4d37 (patch) | |
tree | bfa68a2e81e409c713b5877d4e1577ce5ef1d9b8 /docs/types.rst | |
parent | 683bce18690cc2790b68289278a5d84995472fda (diff) | |
download | dexon-solidity-e3b6c5a4bdbc3066889b6898e5e07bfd599a4d37.tar.gz dexon-solidity-e3b6c5a4bdbc3066889b6898e5e07bfd599a4d37.tar.zst dexon-solidity-e3b6c5a4bdbc3066889b6898e5e07bfd599a4d37.zip |
Update documentation.
Diffstat (limited to 'docs/types.rst')
-rw-r--r-- | docs/types.rst | 22 |
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: |