Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2001-07-29 11:46:39

> From: "Ed Brey" <edbrey_at_[hidden]>
>From: "Kevlin Henney" <kevlin_at_[hidden]>
>> As the base natural language of C++ and Boost is English, I personally
>> prefer to stick to the more easily communicated form, whether written
>> spoken, where the adjective precedes the noun -- it's a const int not
>> int const.
>This is desirable, but isn't always possible. E.g. if you want a
>constant pointer to a non-constant object of type T, you've got no
>choice to put the const last: T* const foo;

Indeed, many things are not always possible, but we should be looking at
addressing the more common cases. Of course, when dealing with a level
of indirection we find that adjective-noun ordering is of little help
(few things are), but this does not mean that it is never useful or

>A tradeoff ensues. You can optimize for English ordering when possible
>or optimize for greatest consistency, i.e. always post-qualified.

I believe that the term "greatest consistency" is almost content free,
because you will find both schemes are greatly consistent -- although
differently consistent and with different resulting emphasis.

>Neither choice is inherently right or wrong. It would be too bad if
>this issue was dropped from the guidelines, leaving uninformed people to
>make arbitrary decisions, rather than choosing the tradeoff best for

If neither approach is right or wrong, then how can you establish a
guideline? Boost cannot educate the masses as to C++ fundamentals -- the
guidelines would turn into an "intro to C++ with critique", which is
not, I believe, its purpose.

>The biggest danger I see with using the prequalified form is that
>programmers may get too confortable with that, and end up not marking
>pointers as constant because they either don't know that they can or
>because it seems unnatural or confusing to do so.

In my training and consulting experience of the last few years I have
not found this to be an issue. This is a matter of a programmer
understanding const-correctness. Programmers who do not understand this
concept misuse both syntax forms in equal measure.

However, what I have found to be an issue is that where the community
once had consistency it now has inconsistency: where once we had one
approach we now have two. I seem to find more programmers dotting const
in all kinds of random places than five years ago thanks to the
qualifier revisionism movement :-(

>My preference is to always use post-qualified. It seemed a bit odd at
>first when I switched, just as any change to a person's schema would,
>but I came to quite like it as it made dealing with more complex
>constness situations easier, and I also like the readability of how the
>type name ends up being at the very beginning of the expression.

Our preferences differ, and I suspect that no amount of debate about
"consistency", "logic", "revisionism", "simplicity", "readability", etc
will change that. Hence, why I do not regard it as a candidate for
inclusion in guidelines. The only thing that can be included reasonably
(and without any bias) is that whatever approach a submitted library
uses it should use only one :->


  Kevlin Henney phone: +44 117 942 2990
  mailto:kevlin_at_[hidden] mobile: +44 7801 073 508 fax: +44 870 052 2289
  Curbralan: Consultancy + Training + Development + Review

Boost list run by bdawes at, gregod at, cpdaniel at, john at