[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [groff] placement of const is _not_ a matter of style ...
From: |
Ralph Corderoy |
Subject: |
Re: [groff] placement of const is _not_ a matter of style ... |
Date: |
Sat, 05 May 2018 23:03:02 +0100 |
Hi Mike,
You dropped the list. That's fine if it were deliberate; just
checking.
> > > >> const char *foo;
> > > >> char const *foo;
> >
> > No, those two have identical meaning.
...
> These examples are found there.
> (( reformatted for emphasis ))
>
> void Foo( int * ptr,
> int const * ptrToConst,
The above `ptrToConst' is the second one I gave.
> int * const constPtr,
> int const * const constPtrToConst )
None of the four are the first one I gave.
> const int *ptrToConst; //identical to: int const *ptrToConst,
The above is the first one I gave. The comment claims it is identical
to my second. I think you're having an off-day of word blindness here.
:-)
Just to make certain we're arguing about the same thing, I'm talking C
here, not C++. I've no idea whether C++ is the same or different in
this respect, and don't wish to learn. :-)
> Please note that I am not trying to pick a fight here.
No, me neither. But there's no harm in first working out why we
disagree, even if we then agree to disagree.
> Is there a path by which the confusions such as these can be
> avoided in the design and implementation of C-like language?
Yes, don't allow two alternatives, only one. Unfortunately,
standardisation arrived too late, but going forward `const after' is
consistent and logical, as I explain in one of my list emails with the
sed and awk showing six varieties.
If you like C, you'll like Go. Its `const' is for constants and they
can be typed, `const foo int64 = 42', or untyped, `const pi =
3.141592653589793238462643383279502884197169399375105820974944592307'.
(I do hope I told bc(1) to do that right.) The untyped ones are
rounded, etc., when actually used for a type, e.g. `var i int = pi //
3'. This allows them to have higher precision than any native type.
https://golang.org/ref/spec#Constant_declarations
Cheers, Ralph.