-
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
Modifier Areas #623
Comments
Modifier areas would be useful in some cases, particularly short, simple contracts. In other cases, though, they would reduce readability, as well as increasing complexity. Some contracts are large, and would have correspondingly large modifier areas. This means that while reading a function, the Also, for a contract that has many modifiers, it will be tempting to nest modifier areas, increasing the contract's complexity. It would also be necessary to intersperse inline modifiers with modifier areas, adding to the mental overhead of the contract reader. Ultimately, modifier areas would be a convenience to the writer of the contract, but often a hindrance to the reader. |
@redsquirrel although I agree with your concerns about "having to scroll up", I think it is much easier to verify the semantics for a group of functions that all have a certain modifier than to check that the modifier is present in every single function. |
No doubt about that! 👍 I'm thinking of the authors that are less responsible. This feature will make it easier for them to create complexity aka bugs. 🐜 |
@chriseth Would you recommend people use modifier areas like this?
becomes
One would have to pick and choose which modifiers get areas and which would have to stay inline. Right? |
@redsquirrel I think when modifiers are not named a/b but something more concrete, it should quite easily follow which one is the more logical to separate like that. E.g. It would be nice to also have multiple modifiers at once:
Otherwise, we might see horizontal space added and vertical space added when going for larger groups (where the gain could otherwise potentially be even bigger, this looks even worse in my opinion).
I'm also concerned about the scrolling issue as well, though. |
And what about nested modifier areas?
...could become...
|
Of course, both nested areas and multi-modifiers will be possible. |
I see this would not allow adding functions with different kinds of return values to the same group modifier. Maybe not a big issue, but usually when I make systems of contracts I like to return values from functions (constant or not) that indicate to calling contracts whether or not the call was successful. A common case would be when contract A calls a method on contract B, then a method on contract C, but only if the call to B was a success. |
@androlo I don't think modifier areas have any effect on return values. |
Ok. No issue then. |
Ah, IC. So basically they are all inlined automatically, or I guess in the case of big nasty modifiers maybe called simply as internal functions. I was thinking in terms of old LLL where you wrapped functions inside modifiers (which were basically just an 'if' or 'when' conditional). I need to start using modifiers... |
perhaps there could be something in the natspec that specifies what modifiers the contract is using? |
Wouldn't it be nice sorting out some of the issues raised in #49 before making it a bit more complex? |
This can be extended with visibility areas: #2608 (comment) |
add EIP-186 to consideration table, remove Type column
This issue has been marked as stale due to inactivity for the last 90 days. |
I'm giving this one more iteration for deciding if we're likely to do this any time soon before letting it go fully stale. There is cause for this and it came up recently elsewhere - but it'll probably take us a while to get to it. |
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. |
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:
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):
If
using modifier x;
(i.e. without curly braces) is used, it applies to the whole contract (including functions before that statement).The text was updated successfully, but these errors were encountered: