-
-
Notifications
You must be signed in to change notification settings - Fork 609
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 trailing coma in asserts #5363
Conversation
|
This is both ugly and consistent with the way that function argument/parameter parsing works... |
|
I guess this is next? if (x,)
{
} |
|
No |
Need a more compelling justification. |
|
@WalterBright Simply the ability to have consistent formatting when passing a series of argument to something. |
|
It's a little early for april fools!
If you're talking about mixins you can use |
|
I'm not talking about mixin. If I was talking about mixin I would have used the word mixin. I'm talking about being able to format argument list consistently. This has been explained both by myself and @Hackerpilot , if you have something to say about this, please do, but if you plan to poison the well by using dismiss terms like "april fool" make sure to do it in a way one doesn't have to question your ability to pass the Turing test. |
|
Take it easy.. Anyway if it's consistent with everything else DMD does then maybe it should be allowed indeed. |
|
No hard feelings. |
Wrong person. |
|
There is a comma.
|
|
@deadalnix: I feel like I'm missing some backstory here. Why do you insist on staying so vague instead of writing a proper explanatory commit message/justification as I'm sure you would do normally? Anyway, it's true that DMD allows trailing commas in other argument lists (function calls, struct literals), so it is indeed consistent in a sense. Not sure whether the better "fix" isn't to just disallow it in the other case, though. |
|
Trailing comma are useful. I do not really wish to go back on this argument, it has been debated to death already in all languages and file format that exists. There are good usability reasons and blame conservation reasons. D already has trailing comma and it is for the best. This is about removing inconsistency. |
I understand why a trailing comma is useful in enum declarations, function argument lists, array literals etc. But assert is not a function, and does not have variadic arguments. My though is that this is good style: int[] x =
[
1,
2,
3,
4,
];but this is not: assert(x, "message",);I'm expecting the first would be preferred, and the latter would be rejected during code review. If I'm not the only one that thinks this, then it would seem we're adding support for a syntax that should never be used. So, do any of the "good usability reasons and blame conservation reasons" actually apply to assert? |
|
@yebblies , both at work and in various projects of mine, I use trailing comma for multiple lines argument lists, and no trailing comma for single line ones. It is relevent when a and b are actually long expressions rather than single letters. While assert is not a function it is to be noted we do this for all argument lists in D, not only function's. We do it for array lterals, for template arguments, for templateand function parameters, and more. Assert is the exception. I do not wish to special case assert formating when condition/message are long. More generally, I think it is not good to allow or disallow trailing comma, or prety much anything else on a case by case basis. That makes the language more complex for no good benefit. |
FYI I've always admired you @deadalnix and it really felt like your comment came out of left-field. I'm sorry if my own comment made it look like I had bad intentions. I can understand the frustration with making DMD pulls which leads to one to being pessimistic (been there, done that..), so let's just say fuck it and bury the hatchets? I agree that we really need to keep these rules consistent. The more special cases involved the more things we need to keep in our head. Btw @deadalnix, is there any way we can make this implementation generic instead of specializing for |
|
@AndrejMitrovic Yes, let's burry the hatchet. Sorry for being hot blooded. As to make this more generic, I don't know much what it involve. I'm only somewhat familiar with DMD source code. if someone more experienced with DMD suggest a way to make this more generic, I'd be happy to do it. |
Cool. :)
Don't worry about it too much, we can live with the special case for now (obviously it was never generic to begin with). Just make it go green so we can merge it. Btw, anyone know what Kenji is up to? Apparently he hasn't had any activity in over 6 months. Hope he's just busy with other things now. :) |
37ba6db to
b8d4e79
Compare
|
Updated, that should be green soon. |
b8d4e79 to
8316f88
Compare
|
Ping ? |
|
To clarify my position: I don't like trailing commas in argument lists, but that doesn't matter because we already have them. I am in favor of this change because consistency is important. |
| if (token.value != TOKrparen) | ||
| { | ||
| msg = parseAssignExp(); | ||
| if (token.value == TOKcomma) nextToken(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In dmd code style, if-condition and its body are placed in their own lines.
|
I've come back.
Currently LGTM. |
8316f88 to
8a08ccc
Compare
8a08ccc to
90aee4f
Compare
|
Done, welcome back @9rnsr ! |
|
LGTM. I'm on a positive stance to the change. When an |
|
Auto-merge toggled on |
Allow trailing coma in asserts
|
<3 |
Grammar change for dlang/dmd#5363
Because