-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Consider relaxing keyword ordering requirements with readonly ref
(struct declaration) vs. ref readonly
(return type declaration)
#1530
Comments
I think this is especially annoying, since the error messages are not very helpful:
|
#946 touches on this a little bit, although I can't tell if it's looking to relax the order of these modifiers for methods or just types. |
C# is indeed irritating when it comes to the ordering of keywords but I suspect this a price paid when committing to a C-like syntax. Also why "fix" this for one scenario? ideally every ordering scenario should be made more flexible not only readonly ref. I recall the PL/I language (and a compiler I created for it) had no such restriction on keyword ordering but the fundamental syntax was designed to support this and I do not think C#'s C-like syntax (which was and is very primitive) can cope with this, you'd probably have to change the grammar. Incidentally PL/I had no reserved words either. More helpful diagnostics would be neat however in which the diagnostic message hinted at a possible ordering problem rather than the blunt message we do see. |
|
@ufcpp Not sure how much of that is still relevant, since |
If we had But I agree the compiler could do a better job at reporting errors in this case. |
Though |
I'm going to close this issue. This repo has enough stale issues as it is, and this particular one has probably joined that club in the meantime. |
This is already championed. See #946 |
Earlier today I was writing something like this:
Being not yet very familiar with all the new
ref
toys, it took me a while to figure out the right ordering(s) of the keywordsref
andreadonly
. It felt like I had to run into a wall a few times until I figured out the correct syntax (at least according to the Roslyn implementation):struct
declaration, only the orderingreadonly ref
is allowed.ref readonly
is allowed.I can't say that I find this particularly intuitive. Of course I'll get used to this very quickly, but enforcing different orderings seems to make things harder than they really need to be.
ref readonly
andreadonly ref
would be allowed?The text was updated successfully, but these errors were encountered: