-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Especially in contracts that model a state machine, it would be convenient to group functions that can be called in a specific state. Currently, the modifiers have to be applied to all these functions individually. This enhancement proposes to provide a syntactic means to apply modifiers to several functions at the same time. This does not only apply to modifiers but also to visibility specifiers. Examples:
contract c {
// ...
modifier inState(state) { if (currentState != state) throw; _ }
using modifier inState(State.transfer) {
function f() { ... }
function g() { ... }
}
using modifier inState(State.cleanup) {
function h() { ... }
function i() { ... }
}
}
This is also convenient to disallow ether transfer using Emmy Noether's famous modifier (derived from Noether's theorem that describes the connection between preservation of ether and the symmetry of the blockchain):
contract c {
modifier noether { if (msg.value > 0) throw; _ }
using modifier noether {
// put all functions in here that are not supposed to receive ether
function f() { ... }
}
}
If using modifier x; (i.e. without curly braces) is used, it applies to the whole contract (including functions before that statement).