aboutsummaryrefslogtreecommitdiffstats
path: root/docs/contracts.rst
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2016-10-16 05:34:35 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2016-10-19 21:02:50 +0800
commit1b3713742f10a4749e6f15b9344d8ffaef19790e (patch)
tree97e978d750a2305d2cb8d4086c78c434a2af29fa /docs/contracts.rst
parentf0f2d5a612e0f646c7d6cec0092d2713ba9d686b (diff)
downloaddexon-solidity-1b3713742f10a4749e6f15b9344d8ffaef19790e.tar.gz
dexon-solidity-1b3713742f10a4749e6f15b9344d8ffaef19790e.tar.zst
dexon-solidity-1b3713742f10a4749e6f15b9344d8ffaef19790e.zip
Document constant functions
Diffstat (limited to 'docs/contracts.rst')
-rw-r--r--docs/contracts.rst27
1 files changed, 24 insertions, 3 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 986d05b3..e2fdf3f3 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -421,9 +421,9 @@ change by overriding).
.. index:: ! constant
-**********
-Constants
-**********
+************************
+Constant State Variables
+************************
State variables can be declared as constant (this is not yet implemented
for array and struct types and not possible for mapping types).
@@ -442,6 +442,27 @@ for these variables and every occurrence is replaced by their constant value.
The value expression can only contain integer arithmetics.
+******************
+Constant Functions
+******************
+
+Functions can be declared constant. These functions promise not to modify the state.
+
+::
+
+ pragma solidity ^0.4.0;
+
+ contract C {
+ function f(uint a, uint b) constant returns (uint) {
+ return a * (b + 42);
+ }
+ }
+
+.. note::
+ Accessor methods are marked constant.
+
+.. warning::
+ The compiler does not enforce yet that a constant method is not modifying state.
.. index:: ! fallback function, function;fallback