-
-
Notifications
You must be signed in to change notification settings - Fork 836
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: Add min and max type #1923
Comments
great VIP! |
I like the functionality but I'm not a fan of the names. Vyper already uses Is there another set of function names that are just as descriptive and not already in use? |
We can just do |
👍 for |
Simple Summary
Add the ability to get the minimum and maximum values for a given type via
min_value(type)
andmax_value(type)
. Remove value constants likeZERO_ADDRESS
,MIN_UINT256
, andEMPTY_BYTES32
Motivation
#1675 adds
empty(type)
to specify an empty section of memory filling the size oftype
. This can be used to simulate "default" values that the EVM provides all types. Some types deserve the ability to also specify their edge-case values, so functionality should be added to ensure this is possible. After this featureset is fully implemented, it makes sense to eliminate the standard constants that are provided with Vyper, as they can be replicated with this more advanced featuresetSpecification
min_value(type)
Returns the minimum representation value of the given type (the most negative value for a given type). Raises a compilation error if the type does not have a minimum representation type (like
bytes32
oraddress
)Throws for more complex types.
max_value(type)
Returns the maximum representation value of the given type (the most positive value for a given type). Raises a compilation error if the type does not have a maximum representation type (like
bytes32
oraddress
)Throws for more complex types.
Built-in Constants
All built-in constants can be replicated as follows:
Backwards Compatibility
Removes built-in constants
Dependencies
No dependencies
Copyright
Copyright and related rights waived via CC0
EDIT: Modified
min
andmax
tomin_value
andmax_value
The text was updated successfully, but these errors were encountered: