aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-12-08 06:36:34 +0800
committerchriseth <c@ethdev.com>2015-12-08 06:36:34 +0800
commitb75b0a37397ff98b3a80df11dcd1e4bbcdee8365 (patch)
treefb26beda629c24ff2b36d4495af8c348c0cd4e09
parent401c694b859f740ee826c1c80f1dd959c081a0dc (diff)
parent92c789a89cdcdb9ef95303f0991e06a833483aaa (diff)
downloaddexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.tar
dexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.tar.gz
dexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.tar.bz2
dexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.tar.lz
dexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.tar.xz
dexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.tar.zst
dexon-solidity-b75b0a37397ff98b3a80df11dcd1e4bbcdee8365.zip
Merge pull request #285 from chriseth/docs
PDFs and some lost changes.
-rw-r--r--docs/conf.py1
-rw-r--r--docs/frequently-asked-questions.rst7
-rw-r--r--docs/style-guide.rst2
-rw-r--r--docs/types.rst6
4 files changed, 15 insertions, 1 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 8319502b..7f5d4514 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -199,6 +199,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
+ ('index', 'solidity.tex', 'Solidity Documentation', 'Ethereum', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index 3ee71e64..94491381 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -547,6 +547,13 @@ Can a regular (i.e. non-contract) ethereum account be closed permanently like a
No. Non-contract accounts "exist" as long as the private key is known by
someone or can be generated in some way.
+What is the difference between `bytes` and `byte[]`?
+====================================================
+
+`bytes` is usually more efficient: When used as arguments to functions (i.e. in
+CALLDATA) or in memory, every single element of a `byte[]` is padded to 32
+bytes which wastes 31 bytes per element.
+
******************
Advanced Questions
******************
diff --git a/docs/style-guide.rst b/docs/style-guide.rst
index 0d7e900f..cd901e63 100644
--- a/docs/style-guide.rst
+++ b/docs/style-guide.rst
@@ -513,7 +513,7 @@ No::
x |= y&&z;
* Operators with a higher priority than others can exclude surrounding
- whitespace in order to denote precidence. This is meant to allow for
+ whitespace in order to denote precedence. This is meant to allow for
improved readability for complex statement. You should always use the same
amount of whitespace on either side of an operator:
diff --git a/docs/types.rst b/docs/types.rst
index a8092403..9811df69 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -119,6 +119,10 @@ Dynamically-sized byte array
`string`:
Dynamically-sized UTF8-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.
+
.. index:: literal, literal;integer
Integer Literals
@@ -261,6 +265,8 @@ Variables of type `bytes` and `string` are special arrays. A `bytes` is similar
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.
+
.. note::
If you want to access the byte-representation of a string `s`, use
`bytes(s).length` / `bytes(s)[7] = 'x';`. Keep in mind