On Saturday, July 28, 2018 11:32:15 PM MDT Ky-Anh Huynh via Digitalmars-d wrote: > Hi, > > is it nice to have a trailing comma in variable declaration: > > [code] > bool > verbose = false, > download_only = false, > no_confirm = false, > show_help = false, > show_version = false, > list_ops = false, > ; > [/code] > > As trailing comma is possible (and it's great) for arrays, > enum,... I wonder why we don't have this fancy thing for > variables declaration. > > Thanks for your reading.
Well, most folks would just make those separate statements, in which case, there would be no commas at all. Some folks do put multiple variable declarations on a single line, but if you do that, a trailing comma looks terrible. I doubt that using a single statement to declare multiple variables but putting it on multiple lines was even a use case that was really considered. Also, a quick test with a C++ compiler shows that it's not legal there, so the rules we have with regard to this probably just came from C++. AFAIK, the only significant change that D has from C/C++ with regards to declaring multiple variables in a single statement is that the * is considered part of the type and thus int* a, b, c; declares three variables of type int* in D, whereas in C/C++, it would declare a single variable of type int* and two of type int. - Jonathan M Davis