Keith Marshall <keith.d.marsh...@ntlworld.com> wrote: |On 05/05/18 10:48, G. Branden Robinson wrote: |> (Incidentally, I share your preference for putting type qualifiers |> [as opposed to storage classes] _after_ the type name itself. It |> makes complex declarations easier to understand.) | |Personally, I consider that to be a poor choice ... especially if you |are making it on purely stylistic grounds; conventionally: | | const int foo; | |is more common than: | | int const foo; | |but that's not the real issue. In practice, the placement of "const" |qualifiers is *not* arbitrary; far from "making the declaration easier |to understand", it can effect a subtle change in meaning. For example, |in C code, it is very common to see: | | const char *foo; | |which means something very different from: | | char const *foo; | |Your stylistic preference might encourage the latter idiom, but it |likely isn't what you meant. (The former declares a mutable pointer to |an immutable C-string; the latter is an immutable pointer to a mutable |C-string).
It does not? I finally ended up using this latter style because it mirrors the spoken language: it is "a pointer to constant character(s)". I think Stroustrup used this in his book accompanying C++ ~98, and Brian Kernighan also refers to spoken language in the video that was linked in the other thread. And then it is also more consistent, consider char const * const * which would need to be "const char const * *" in the "standard" notation, but _that_ would be something different, then. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)