VIP: 990
Title: Constant Variables
Author: Ryuya Nakamura (@nrryuya)
Type: Standard Track
Status: Draft
Created: 10-8-2018
Adding constant variables (like Solidity's one) for readability and usability.
Adding constant variables which is assigned from an constant expression and can be used in whole the contract. Every occurrence is replaced by the constant expression at compile time.
Constant variables reduces hard coding of same value repeatedly and improve readability. It also helps code auditing.
Spec on declaring constant variables.
# Block interval of Plasma chain
CHILD_BLOCK_INTERVAL: constant(uint256) = 1000
No problem
Copyright and related rights waived via CC0
I wonder
I think we should leave types of the equation, and just follow the principal that each constant is a literal.
CHILD_BLOCK_INTERVAL: constant = 100
Also I think there is merit in limiting constants to only be defined at the top of a program (also outside functions).
I think constants should have types.
Currently I have to do like this within function.
secondsPerMonth:uint256(sec/mon) = 2592000 # 30脳24脳60脳60
seconds:timedelta = _durationInMonths * secondsPerMonth
typed constants will make a code cleaner
Also I think there is merit in limiting constants to only be defined at the top of a program (also outside functions).
You mean the definition of constants is above the definition of interfaces, events and storage variables?
@nrryuya yes, above the all the functions just after globals perhaps?
Starting on this.
Most helpful comment
@nrryuya yes, above the all the functions just after globals perhaps?