Skip to content
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

VIP: Support @pure decorator #2041

Closed
fubuloubu opened this issue Jun 25, 2020 · 1 comment · Fixed by #2052
Closed

VIP: Support @pure decorator #2041

fubuloubu opened this issue Jun 25, 2020 · 1 comment · Fixed by #2052
Assignees
Labels
VIP: Approved VIP Approved

Comments

@fubuloubu
Copy link
Member

fubuloubu commented Jun 25, 2020

Simple Summary

Support the use of @pure as a decorator for methods

Motivation

To be consistent with the ABI stateMutability field, we should add support for specifying a method as @pure.

Specification

A method that is decorated as @pure must not read any blockchain state such as storage variables, environment variables, querying contract code or account balances, or making a call to nonpure methods, or to other contracts. In the event this happens, this should raise an exception that uniquely details a violation of reading blockchain state. Such a function might be useful for complex math or other purposes.

A method decorated with @pure looks like:

@pure
@public
def getMaff() -> uint256:
    return 1 + 2

Backwards Compatibility

No backwards compatibility issues

Dependencies

No dependencies. Related to #2040

References

Copyright

Copyright and related rights waived via CC0

@fubuloubu fubuloubu changed the title VIP: Support pure decorator VIP: Support @pure decorator Jun 25, 2020
@fubuloubu fubuloubu added this to the v0.2 Release milestone Jun 26, 2020
@fubuloubu fubuloubu self-assigned this Jun 26, 2020
@fubuloubu
Copy link
Member Author

Remove this line in docs/index.rst:
Anything marked constant is not allowed to change the state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VIP: Approved VIP Approved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants