[Top][All Lists]

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

Re: [groff] hyphenation issues

From: Ingo Schwarze
Subject: Re: [groff] hyphenation issues
Date: Sat, 5 May 2018 20:05:20 +0200
User-agent: Mutt/1.8.0 (2017-02-23)

Hi Ralph,

Ralph Corderoy wrote on Sat, May 05, 2018 at 05:08:22PM +0100:

>>   char const *foo;

> I used your syntax for decades and only switched in the last year after
> chatting to a programmer that's always done it the other way since
> introducing the Small C compiler into his company to replace assembler;
> so, quite a while.  He'd had no external influences so worked out what
> he thought was logical.

Even though you are right that "char const" is simpler
than "const char" because it uses exactly the same rules of
interpretation except that it does *not* need the additional
rule "if const comes first, it applies to what is right to it",
i strongly object to your argument.

Simplicity of understanding results from three incommensurable
components: (1) objective simplicity, (2) convention and habit,
(3) consistency within a code base.

In the case at hand, (1) undeniably favours "char const",
(2) undeniably favours "const char", and i'm not even talking
about (3) here.  Enjoy changing it all over place.

The weight of (2) is very heavy in this case.  In practice, coding
styles using "char const" are rare to the point that i wasn't even
aware until now that they exist at all.  It is *not* a coincidence
that the colleague you got the idea from "had no external influences".
So with "char const *", you are going to confuse almost everybody -
we have seen ample evidence on this list that some people will even
think what you mean is "char *const", so the potential confusion
is very considerable.  It will slow down code audits and annoy code
auditors because due to your idiosyncratic - no matter how logical -
coding style, they are inevitably distracted from aspects that
matter functionally.

The weight of (1) is very light in the case at hand.  The rule "as
an exception, if const comes first, it operates to the right" is
very easy to remeber and understand, and the coding style rule "if
you can use this exception, do use it" is practically ubiquitious,
even if almost never stated explicitly.  Even in the inconceivable
case that someone does not know what "const char" means because he
is used to "char const", it is still impossible to misunderstand:
What else could "const char" possibly mean?  So even (1) provides
no real argument against using "const char".

There are many aspects of coding style where either possibility
is in widespread use.  This is not one of them, so adopting it
is clearly a terrible idea.


By the way, using "char const" doesn't make understanding

  char *const *evil[2][3];

any easier for people who do not know the rules...

reply via email to

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