aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/abi-spec.rst2
-rw-r--r--docs/contracts.rst23
-rw-r--r--docs/grammar.txt2
-rw-r--r--docs/miscellaneous.rst5
-rw-r--r--docs/types.rst2
5 files changed, 28 insertions, 6 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index 159bd6c7..036b1ac8 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -295,7 +295,7 @@ The JSON format for a contract's interface is given by an array of function and/
- `outputs`: an array of objects similar to `inputs`, can be omitted if function doesn't return anything;
- `constant`: `true` if function is :ref:`specified to not modify blockchain state <view-functions>`);
- `payable`: `true` if function accepts ether, defaults to `false`;
-- `statemutability`: a string with one of the following values: `view` (same as `constant` above), `nonpayable` and `payable` (same as `payable` above).
+- `statemutability`: a string with one of the following values: `pure` (:ref:`specified to not read blockchain state <pure-functions>`), `view` (same as `constant` above), `nonpayable` and `payable` (same as `payable` above).
`type` can be omitted, defaulting to `"function"`.
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/grammar.txt b/docs/grammar.txt
index 36ba36f0..041728c5 100644
--- a/docs/grammar.txt
+++ b/docs/grammar.txt
@@ -53,7 +53,7 @@ ArrayTypeName = TypeName '[' Expression? ']'
FunctionTypeName = 'function' TypeNameList ( 'internal' | 'external' | StateMutability )*
( 'returns' TypeNameList )?
StorageLocation = 'memory' | 'storage'
-StateMutability = 'constant' | 'view' | 'payable'
+StateMutability = 'pure' | 'constant' | 'view' | 'payable'
Block = '{' Statement* '}'
Statement = IfStatement | WhileStatement | ForStatement | Block | InlineAssemblyStatement |
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``.
diff --git a/docs/types.rst b/docs/types.rst
index 9c1c73c6..fb88b006 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -337,7 +337,7 @@ be passed via and returned from external function calls.
Function types are notated as follows::
- function (<parameter types>) {internal|external} [constant|view|payable] [returns (<return types>)]
+ function (<parameter types>) {internal|external} [pure|constant|view|payable] [returns (<return types>)]
In contrast to the parameter types, the return types cannot be empty - if the
function type should not return anything, the whole ``returns (<return types>)``