-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to constants through contract names #1290
Comments
We still have to figure out how we want constants to behave exactly. Currently, I think you might be able to access private information via constants, which is perhaps not such a good idea. |
Now that we have the pure check, it should be fine to do this at least for actually pure constants. |
As a side note to this ticket: To simulate the desired constant behavior until it's fully supported in the language I'm using a workaround via libraries:
To be frank, I actually don't know the cost of simulating constants via library functions, because you have an additional function on the callstack and memory every time you access it, but it does the trick and gives me what I need for more efficient coding. Once constants are supported fully, it is not too hard to turn the library into a contract and search/replace its usage to remove the I'm not worried about gas cost as the solutions that use this approach run on a permissioned EVM with no gas limit, but it would be great to get your opinion on the above, @chriseth. |
I am leaning towards that constants should be supported in interfaces instead. |
It seems this is solved with Solidity 0.6 |
I looked at the Solidity 0.6 release notes and did not see how this is solved with that release. Can anyone point to an example or other relevant docs? |
Ah sorry, I thought I tried the example, but I must have made a mistake. |
can confirm, 100% still an issue |
Design call: moving it into the icebox because there seems to be not too much interest. We may allow constants at file level in the future instead. |
Just for reference - issue about constants at file level: #9671. |
This is still an issue on 0.8.15: Contract Test1 {
uint256 public constant WAD = 1e18;
}
Contract Test2 {
function getWad() external pure returns (uint256) {
return Test1.WAD();
}
} returns |
I also believe that something like this would be perfectly possible type(ContractWithConstant).CONSTANT_NAME very similar to type(uint).max |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
It is currently possible to do this:
But surely it should be possible to do this:
The text was updated successfully, but these errors were encountered: