aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorChris Ward <chris.ward@ethereum.org>2019-01-07 21:14:26 +0800
committerChris Ward <chris.ward@ethereum.org>2019-01-07 21:14:26 +0800
commit1da2c1f7e4a11f44a1a106088e2e99696658849a (patch)
treea5125fd1399d0e0328d758da9c641d612ab9d330 /docs
parentaca9e581454585fab494a87febb7da3278e3aa7b (diff)
downloaddexon-solidity-1da2c1f7e4a11f44a1a106088e2e99696658849a.tar.gz
dexon-solidity-1da2c1f7e4a11f44a1a106088e2e99696658849a.tar.zst
dexon-solidity-1da2c1f7e4a11f44a1a106088e2e99696658849a.zip
Split Constant State Variables doc
Diffstat (limited to 'docs')
-rw-r--r--docs/contracts.rst36
-rw-r--r--docs/contracts/constant-state-variables.rst35
2 files changed, 36 insertions, 35 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 746f6e00..c9adb03b 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -441,41 +441,7 @@ all symbols visible from the function are visible in the modifier. Symbols
introduced in the modifier are not visible in the function (as they might
change by overriding).
-.. index:: ! constant
-
-************************
-Constant State Variables
-************************
-
-State variables can be declared as ``constant``. In this case, they have to be
-assigned from an expression which is a constant at compile time. Any expression
-that accesses storage, blockchain data (e.g. ``now``, ``address(this).balance`` or
-``block.number``) or
-execution data (``msg.value`` or ``gasleft()``) or makes calls to external contracts is disallowed. Expressions
-that might have a side-effect on memory allocation are allowed, but those that
-might have a side-effect on other memory objects are not. The built-in functions
-``keccak256``, ``sha256``, ``ripemd160``, ``ecrecover``, ``addmod`` and ``mulmod``
-are allowed (even though, with the exception of ``keccak256``, they do call external contracts).
-
-The reason behind allowing side-effects on the memory allocator is that it
-should be possible to construct complex objects like e.g. lookup-tables.
-This feature is not yet fully usable.
-
-The compiler does not reserve a storage slot for these variables, and every occurrence is
-replaced by the respective constant expression (which might be computed to a single value by the optimizer).
-
-Not all types for constants are implemented at this time. The only supported types are
-value types and strings.
-
-::
-
- pragma solidity >=0.4.0 <0.6.0;
-
- contract C {
- uint constant x = 32**22 + 8;
- string constant text = "abc";
- bytes32 constant myHash = keccak256("abc");
- }
+.. include:: contracts/constant-state-variables.rst
.. index:: ! functions
diff --git a/docs/contracts/constant-state-variables.rst b/docs/contracts/constant-state-variables.rst
new file mode 100644
index 00000000..3e615ed0
--- /dev/null
+++ b/docs/contracts/constant-state-variables.rst
@@ -0,0 +1,35 @@
+.. index:: ! constant
+
+************************
+Constant State Variables
+************************
+
+State variables can be declared as ``constant``. In this case, they have to be
+assigned from an expression which is a constant at compile time. Any expression
+that accesses storage, blockchain data (e.g. ``now``, ``address(this).balance`` or
+``block.number``) or
+execution data (``msg.value`` or ``gasleft()``) or makes calls to external contracts is disallowed. Expressions
+that might have a side-effect on memory allocation are allowed, but those that
+might have a side-effect on other memory objects are not. The built-in functions
+``keccak256``, ``sha256``, ``ripemd160``, ``ecrecover``, ``addmod`` and ``mulmod``
+are allowed (even though, with the exception of ``keccak256``, they do call external contracts).
+
+The reason behind allowing side-effects on the memory allocator is that it
+should be possible to construct complex objects like e.g. lookup-tables.
+This feature is not yet fully usable.
+
+The compiler does not reserve a storage slot for these variables, and every occurrence is
+replaced by the respective constant expression (which might be computed to a single value by the optimizer).
+
+Not all types for constants are implemented at this time. The only supported types are
+value types and strings.
+
+::
+
+ pragma solidity >=0.4.0 <0.6.0;
+
+ contract C {
+ uint constant x = 32**22 + 8;
+ string constant text = "abc";
+ bytes32 constant myHash = keccak256("abc");
+ }