[EXPERIMENT] trailing comma in argument list should be an error#12684
[EXPERIMENT] trailing comma in argument list should be an error#12684WalterBright wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#12684" |
He did?
To save you some time, here are some more:
|
In my naivity, I mentally inserted a comma. :-) |
I'm afraid I'm not seeing the compelling advantage of: over: |
Geod24
left a comment
There was a problem hiding this comment.
Please no. You might not find a use for it, but many people do.
Namely, it makes string-based code generation easier, and it's more git friendly as you don't have to modify an unrelated line when you add an entry to your array initializer / enum / whatnot.
Plus, what would this deprecation achieve ? What's the issue with them ?
This seems highly unlikely. Looks to me like most uses are rare and accidental.
That's true. But not that much easier. hdrgen.d deals with commas-as-separators all over it, and it's trivial: https://github.com/dlang/dmd/blob/master/src/dmd/hdrgen.d#L3158
See #12684 (comment)
Good taste. Does: look like anything but crap? Code should be crafted to be pleasing to the eye. It's not a technical issue, it's a human factors issue. When I see stuff like that, it looks like someone just dented my car. |
We may be stuck with it. But that's no rationale to extend it to case statements. |
No, they are not. If you make that claim, please back it up. Here's what I got when I tried to compile Phobos (the error triggered in druntime, but it was while compiling Phobos): Because of this: So I made it a deprecation, in order to be able to build and test your claims. I got two more uses:
https://github.com/dlang/phobos/blob/0b7bf8dc1fe0b035e0f3f039bdd1e365d11223bc/std/traits.d#L800-L807 Then I went on to compile our code, and it triggered cases in Vibe.d: And in our code: https://github.com/bosagora/agora/blob/490b18e32e87e39de68094de549f2e93d5fa04d0/source/agora/common/Config.d#L290-L317 There are two patterns that emerge from this:
The fact you can do it differently with "a bit more work" doesn't negate the point.
My point was about being more "git friendly". That's not a matter of style or aesthetics. Without trailing commas, you have to change surrounding lines when moving an entry / adding a new one. With trailing commas you don't. There's nothing subjective about this.
This makes absolutely no sense. Since when is it acceptable to deprecate a tiny but convenient feature used by many projects out there because you suddenly don't like how it looks ? If I want my code to be formatted according to someone else's questionable taste, I'd be using Golang. |
They would be very useful if C++ had them for LDC as one example, what with LLVM interfaces changing frequently. See also Mathis' post above.
Then you should open a reversion PR on that PR. Closing this. |
The
I never did. I made a mistake implementing the parser. |
So I did 10 years ago. Mea Culpa. |
I think you made the right call back then. I don't remember anyone complaining about trailing commas, ever, before today. |
|
And here is the spec change which introduced it in the grammar: |
For clarity, this pull request was an experiment to check the CI fallout - see #12677 (comment) . @WalterBright's initiative to remove it from the language was based on the hypothesis that this feature isn't actually used by anyone (which has now been debunked). I will update the title accordingly to avoid further confusion. |
|
The only argument against this feature is style and "it's ugly". But the right place to enforce style guidelines is dscanner, not dmd. |
@ibuclaw discovered that trailing commas in argument lists are allowed. This was never intended. This PR is an experiment so see if code depends on it.