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
Should we allow duplicate attributes? #24767
Comments
Right, we could decide to enable |
I think we didn't have a use case for multiple and it led to questions about redefinition vs. multiple definition during assignment, and when retrieving attributes we do so by name so having multiple with the same name added complexity when there was no use case. |
Stylistically, I like Michael's varargs proposal over multiple attributes of the same kind as the approach here. But I don't know whether that requires more from attributes than they support today (and other attributes may not be as amenable to a varargs approach as this one looks like it may be?) Or wait, is varargs already enabled and this issue is just asking about permitting both forms? (I'm just seeing now that Jade's screenshot starts with the varargs form). |
Currently, the This is similar to the approach I took with In my opinion, duplicated attributes is cleaner and I would rather us support this, then have to do the varargs |
I see, thanks. And I'd agree that a 1+(1 optional)-arg attribute like this is less ideal for varargs than a simple 1-arg attribute which is what I was imagining this was (and alluding to in saying other attributes may not be as amenable). Based on that, I agree that multiple attributes seems preferable to varargs here, assuming we want to keep that optional comment field. For my own edification, what does the comment field do (mechanically speaking) vs. using |
Currently, nothing. It offers no benefit over a comment. I think there are future goals for its usage in tools (for example, |
Tooling (like chplcheck) can make sense of why it was disabled. Not needed now, but could be useful if it were to provide a detailed report (10 warnings, 7 silenced, here's how).
Because in general, attributes can contain additional metadata (like the In general, if any time you may repeat an attribute, you need to make it a vararg attribute, that would leave a bad taste in my mouth. I think of attributes as function calls (ish), and saying "you can only call a function once, so if you need to pass more data, use varargs" seems odd. It also goes against precedent in Rust's (?) and Python's attributes. |
Motivated by Jade's code in the below screenshot.
My intention with the
@chplcheck.ignore
attribute was for it to target a single rule. Thus, to silence multiple rules, you could just list the attribute twice. However, this is currently disallowed by the compiler (and explicitly listed as a limitation in the tech note for attributes).I understand that not all attributes should support being used multiple times (e..g, maybe not
deprecated
orunstable
). But I see no problem with allowing some (likechplcheck.ignore
) to be repeated.The text was updated successfully, but these errors were encountered: