aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-23 02:09:35 +0800
committerGitHub <noreply@github.com>2017-08-23 02:09:35 +0800
commit0ffc5db82b24b4897d5d09cebbaadba37fa63b45 (patch)
tree023cefa5a9f00b0e6a5bf84d02745ab8e6666121 /docs
parent210b4870a805620329793c8ba2177a3ff6e7b477 (diff)
parentb1cdf81506de39502db0fb4a4b55ba8155f853ab (diff)
downloaddexon-solidity-0ffc5db82b24b4897d5d09cebbaadba37fa63b45.tar.gz
dexon-solidity-0ffc5db82b24b4897d5d09cebbaadba37fa63b45.tar.zst
dexon-solidity-0ffc5db82b24b4897d5d09cebbaadba37fa63b45.zip
Merge pull request #2762 from ethereum/statemutability-view
Introduce view state-mutability (keep constant as alias)
Diffstat (limited to 'docs')
-rw-r--r--docs/abi-spec.rst2
-rw-r--r--docs/contracts.rst19
-rw-r--r--docs/grammar.txt2
-rw-r--r--docs/miscellaneous.rst5
-rw-r--r--docs/types.rst2
5 files changed, 17 insertions, 13 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index a9110a0a..159bd6c7 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -293,7 +293,7 @@ The JSON format for a contract's interface is given by an array of function and/
* `name`: the name of the parameter;
* `type`: the canonical type of the parameter.
- `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 <constant-functions>`);
+- `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).
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 7b972e17..0f1a882c 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -461,29 +461,32 @@ value types and strings.
}
-.. _constant-functions:
+.. _view-functions:
-******************
-Constant Functions
-******************
+**************
+View Functions
+**************
-Functions can be declared constant in which case they promise not to modify the state.
+Functions can be declared ``view`` in which case they promise not to modify the state.
::
pragma solidity ^0.4.0;
contract C {
- function f(uint a, uint b) constant returns (uint) {
+ function f(uint a, uint b) view returns (uint) {
return a * (b + 42);
}
}
.. note::
- Getter methods are marked constant.
+ ``constant`` is an alias to ``view``.
+
+.. note::
+ Getter methods are marked ``view``.
.. warning::
- The compiler does not enforce yet that a constant method is not modifying state.
+ The compiler does not enforce yet that a ``view`` method is not modifying state.
.. index:: ! fallback function, function;fallback
diff --git a/docs/grammar.txt b/docs/grammar.txt
index 76827a77..36ba36f0 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' | 'payable'
+StateMutability = 'constant' | 'view' | 'payable'
Block = '{' Statement* '}'
Statement = IfStatement | WhileStatement | ForStatement | Block | InlineAssemblyStatement |
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 199182d3..7889fff2 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -505,11 +505,12 @@ Function Visibility Specifiers
Modifiers
=========
+- ``view`` for functions: Disallow 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: Disallows modification of state - this is not enforced yet.
+- ``constant`` for functions: Same as ``view``.
- ``anonymous`` for events: Does not store event signature as topic.
- ``indexed`` for event parameters: Stores the parameter as topic.
-- ``payable`` for functions: Allows them to receive Ether together with a call.
Reserved Keywords
=================
diff --git a/docs/types.rst b/docs/types.rst
index 13c848c2..9c1c73c6 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|payable] [returns (<return types>)]
+ function (<parameter types>) {internal|external} [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>)``