aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-17 03:51:47 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-24 20:46:18 +0800
commit93e6e83093ecd4a31035e7b6a62adabd3cd81c5a (patch)
treea7ce04c141565b633a2f47d64fe491d172ebfe7a
parente9a9a07d94d35fd9b84b16b7bd4bf8ab0b396d22 (diff)
downloaddexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.tar
dexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.tar.gz
dexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.tar.bz2
dexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.tar.lz
dexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.tar.xz
dexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.tar.zst
dexon-solidity-93e6e83093ecd4a31035e7b6a62adabd3cd81c5a.zip
Document pure functions
-rw-r--r--docs/contracts.rst23
-rw-r--r--docs/miscellaneous.rst5
2 files changed, 25 insertions, 3 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 0f1a882c..50e7f3d1 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -475,7 +475,7 @@ Functions can be declared ``view`` in which case they promise not to modify the
contract C {
function f(uint a, uint b) view returns (uint) {
- return a * (b + 42);
+ return a * (b + 42) + now;
}
}
@@ -488,6 +488,27 @@ Functions can be declared ``view`` in which case they promise not to modify the
.. warning::
The compiler does not enforce yet that a ``view`` method is not modifying state.
+.. _pure-functions:
+
+**************
+Pure Functions
+**************
+
+Functions can be declared ``pure`` in which case they promise not to read from or modify the state.
+
+::
+
+ pragma solidity ^0.4.0;
+
+ contract C {
+ function f(uint a, uint b) pure returns (uint) {
+ return a * (b + 42);
+ }
+ }
+
+.. warning::
+ The compiler does not enforce yet that a ``pure`` method is not reading from the state.
+
.. index:: ! fallback function, function;fallback
.. _fallback-function:
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 7889fff2..e78c4807 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -500,12 +500,13 @@ Function Visibility Specifiers
- ``internal``: only visible internally
-.. index:: modifiers, constant, anonymous, indexed
+.. index:: modifiers, pure, view, payable, constant, anonymous, indexed
Modifiers
=========
-- ``view`` for functions: Disallow modification of state - this is not enforced yet.
+- ``pure`` for functions: Disallows modification or access of state - this is not enforced yet.
+- ``view`` for functions: Disallows modification of state - this is not enforced yet.
- ``payable`` for functions: Allows them to receive Ether together with a call.
- ``constant`` for state variables: Disallows assignment (except initialisation), does not occupy storage slot.
- ``constant`` for functions: Same as ``view``.