diff options
author | chriseth <c@ethdev.com> | 2017-03-09 21:39:30 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-13 20:30:23 +0800 |
commit | bdbd3b158eb68d36a56e0220c7b02960bc71ccb1 (patch) | |
tree | 62e32bd453de4c9d3c855e42f68e71662c6e0bee /docs | |
parent | 592cec7e9074313e7ce5539769c065ecf5cbba12 (diff) | |
download | dexon-solidity-bdbd3b158eb68d36a56e0220c7b02960bc71ccb1.tar.gz dexon-solidity-bdbd3b158eb68d36a56e0220c7b02960bc71ccb1.tar.zst dexon-solidity-bdbd3b158eb68d36a56e0220c7b02960bc71ccb1.zip |
Extend documentation for constant state variables.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index f15dc122..890745ce 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -429,8 +429,15 @@ Constant State Variables ************************ State variables can be declared as constant. In this case, they have to be -assigned a value or expression which is a constant at compile time. The compiler does -not reserve a storage slot for these variables and every occurrence is +assigned a value or expression which is a constant at compile time. 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. This makes it possible +to create constant memory arrays as lookup-tables +(although this is not yet fully implemented). +Expressions that depend on blockchain data like `now`, `this.balance` or +`block.number` or perform any storage access are disallowed. + +The compiler does not reserve a storage slot for these variables and every occurrence is replaced by their constant value (which might be computed by the optimizer). Not all types for constants are implemented at this time. The only supported types are |