[Development] commas in ctor-init-lists

Edward Welbourne edward.welbourne at qt.io
Wed Jun 1 16:50:49 CEST 2016

Jędrek remarked:
>> argument about how similar code is to natural language is a bit odd
>> to me, I'm not aware of any successful programing language that
>> simulates natural grammar :-) .

On 1st June 2016 at 16:17 Konstantin Tokarev added to the discussion:
> For example, Perl is somewhat closer to it than C++, it's designed by
> linguist after all.

I suspect Jędrek was aware of this and actively meant to insinuate
something about whether perl is a "successful programing language".

For my own part, although I do enjoy perl's scope for poetic choices
about how to phrase things, I must confess its linguistic pretensions
mostly lead to programmers, who *haven't* thought carefully about the
future readers of their code, writing code that's made harder to read.
The freedom to express things in Tim Toady's many ways does make it
possible to write elegant and poetic perl, but most programmers are
lousy poets in too much of a hurry to hack something together to worry
about elegance.  Much as may be said for the natural language we write.

In any case, C++ isn't perl and doesn't come close to it in terms of
naturality of linguistic form.  C++ isn't even Algol, in which
multi-word identifiers were allowed to embed (ignored) spaces, making
camelCase redundant.  So whether C++ reads, or is typeset, like English
is far less important than whether it is easy to see, at a glance,
whether it is correct.

As to commas normally appearing at the end of prior text: where I
learned my anglic, colons do the same - yet we quite commonly split a
class constructor just before the colon, that introduces the
initialization before the body, rather than just after it.  Doing the
same for the comma-joined subsequent initializer list is no worse - and
arguably at least consistent with the treatment of the colon.

As to that, I can see why some like the comma-first style (and I notice
emacs does a decent job of indenting it sensibly), although I don't
really see a huge win in either direction and my eyes parse each with
roughly equal ease.

Speaking of colons, one coder's "butt-ugly" is another's "callipygian",
I guess,


More information about the Development mailing list