-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
allow self
as default argument
#3648
Comments
i think
|
There are a couple of (library) use cases where "function overloading" using Another approach would be having something like |
self
as default argument
delegatecalls change code, so it could indeed have semantic changes! |
Quickly linking to this VIP #3701 which proposes to replace # pragma version ^0.3.10
_COLLISION_OFFSET: constant(bytes1) = 0xFF
@external
@view
def compute_address(salt: bytes32, bytecode_hash: bytes32, deployer: address=self.address) -> address:
"""
@dev Returns the address where a contract will be stored if
deployed via `deployer` using the `CREATE2` opcode.
Any change in the `bytecode_hash` or `salt` values will
result in a new destination address.
@param salt The 32-byte random value used to create the contract
address.
@param bytecode_hash The 32-byte bytecode digest of the contract
creation bytecode.
@return address The 20-byte address where a contract will be stored.
"""
data: bytes32 = keccak256(concat(_COLLISION_OFFSET, convert(deployer, bytes20), salt, bytecode_hash))
return convert(convert(data, uint256) & convert(max_value(uint160), uint256), address) If you think about it, depending on whether you use the default argument or not, the visibility modifier does implicitly change. The overloaded function without the |
Typically, instance variables in Python would not be allowed as a default argument, but I think in this case it makes sense to allow |
I think it would be a nice feature to allow non-literal and built-in environment variable values as default arguments.
Example Use Case
The text was updated successfully, but these errors were encountered: