aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorWilliam Morriss <wjmelements@gmail.com>2018-05-31 01:34:01 +0800
committerWilliam Morriss <wjmelements@gmail.com>2018-05-31 01:34:01 +0800
commit78b8baede77088f41e84fe88ab5c8a9d7dc4f162 (patch)
treec7015c8953fc07d90d7f30c1e863132421245355 /docs
parent7bc36204d385893702a944f32aa1902aca1e7377 (diff)
downloaddexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.tar
dexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.tar.gz
dexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.tar.bz2
dexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.tar.lz
dexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.tar.xz
dexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.tar.zst
dexon-solidity-78b8baede77088f41e84fe88ab5c8a9d7dc4f162.zip
keep stub in value types section, and move discussion to Arrays section
Diffstat (limited to 'docs')
-rw-r--r--docs/types.rst24
1 files changed, 11 insertions, 13 deletions
diff --git a/docs/types.rst b/docs/types.rst
index 400c6fde..2a716e88 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -218,6 +218,14 @@ Members:
It is possible to use an array of bytes as ``byte[]``, but it is wasting a lot of space, 31 bytes every element,
to be exact, when passing in calls. It is better to use ``bytes``.
+Dynamically-sized byte array
+----------------------------
+
+``bytes``:
+ Dynamically-sized byte array, see :ref:`arrays`. Not a value-type!
+``string``:
+ Dynamically-sized UTF-8-encoded string, see :ref:`arrays`. Not a value-type!
+
.. index:: address, literal;address
.. _address_literals:
@@ -505,18 +513,6 @@ them can be quite expensive, we have to think about whether we want them to be
stored in **memory** (which is not persisting) or **storage** (where the state
variables are held).
-Dynamically-sized byte array
-----------------------------
-
-``bytes``:
- Dynamically-sized byte array, see :ref:`arrays`. Not a value-type!
-``string``:
- Dynamically-sized UTF-8-encoded string, see :ref:`arrays`. Not a value-type!
-
-As a rule of thumb, use ``bytes`` for arbitrary-length raw byte data and ``string``
-for arbitrary-length string (UTF-8) data. If you can limit the length to a certain
-number of bytes, always use one of ``bytes1`` to ``bytes32`` because they are much cheaper.
-
Data location
-------------
@@ -602,8 +598,10 @@ shaves off one level in the type from the right).
Variables of type ``bytes`` and ``string`` are special arrays. A ``bytes`` is similar to ``byte[]``,
but it is packed tightly in calldata. ``string`` is equal to ``bytes`` but does not allow
length or index access (for now).
-
So ``bytes`` should always be preferred over ``byte[]`` because it is cheaper.
+As a rule of thumb, use ``bytes`` for arbitrary-length raw byte data and ``string``
+for arbitrary-length string (UTF-8) data. If you can limit the length to a certain
+number of bytes, always use one of ``bytes1`` to ``bytes32`` because they are much cheaper.
.. note::
If you want to access the byte-representation of a string ``s``, use