groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [groff] hyphenation issues


From: Keith Marshall
Subject: Re: [groff] hyphenation issues
Date: Sat, 5 May 2018 14:01:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

On 05/05/18 12:40, G. Branden Robinson wrote:
> At 2018-05-05T11:51:00+0100, Keith Marshall 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;
> 
> Yes, it's more common.  And ill-advised.

On the contrary; I consider your proposed style to be ill-advised,
simply because it is potentially confusing.

>> but that's not the real issue.  In practice, the placement of "const"
>> qualifiers is *not* arbitrary;
> 
> That's true.  It largely follows from the English practice of placing
> adjectives before nouns.  That's good comment style but risky C style.
> 
>> far from "making the declaration easier to understand", it can effect
>> a subtle change in meaning.
> 
> Indeed.
> 
>> For example,
>> in C code, it is very common to see:
>>
>>   const char *foo;
>>
>> which means something very different from:
>>
>>   char const *foo;
> 
> Actually, it doesn't.  Try it.

Okay, but that just reinforces my aversion to your style.  You suggest
that it makes declarations easier to understand; I contend quite the
opposite.  See, when I first learned C, close to 30 years ago -- when
admittedly, "const" semantics were perhaps less clearly defined -- I was
taught to:

  - find the symbol name
  - look right, for parentheses
  - look left, token by token, to find the type

By that rule:

  char const *foo;

would be read as:

  - foo is a variable (not function)
  - foo is a pointer (to data of type not yet established)
  - foo is constant
  - foo is a constant pointer to data of type char

whereas:

  const char *foo;

*unambiguously* reads as:

  - foo is a variable (not function)
  - foo is a pointer (to data of type not yet established
  - foo is a pointer to data of type char
  - foo is a pointer to data of type char, which is constant

-- 
Regards,
Keith.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]