aboutsummaryrefslogtreecommitdiffstats
path: root/docs/contracts.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/contracts.rst')
-rw-r--r--docs/contracts.rst23
1 files changed, 22 insertions, 1 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: