Hi there,
When you make "Foo**" -> "const Foo * const * const" prohibited by default,
you expect software developers (both experienced and newcomers) to start
using explicit conversion when it is necessary.
The examples I wrote is just one case how it will look like:
"
subfunc((some_type)arr_of_ptr);
".
It looks like an awful code style irrespectively of what actual 'some_type'
you are going to use.
It might be
subfunc((void*)arr_of_ptr);
or
subfunc((const Foo*const*const)arr_pf_ptr);
or
subfunc((TCustomType)arr_of_ptr).
And in the last case you should invent a new TCustomType name somehow to
denote "const".
If you use all three const type in the example ("const Foo * const *
const"), you can have the type name as "TAllConstFooPtr" or something like
that).
But if you skip some of "const", type naming might be less readable and
understandable.
All-CONST == CONST INVARIANT == "[IN]PARAMETER".
Yep, we use 'void Func(int i)' instead of 'void Func(const int i)' cause
this is how traditions work :)
But anyway, all three variants will make the code less readable :(
This is one more aspect (alongside of BROKEN BACK-COMPATIBILITY and WRONG
INTERPRETATION OF TYPE CONVERSION), which should be taken into account when
you are going to
change somehow GCC compiler :D
Respectfully,
Aleksandr G Povaliaev.
пн, 8 дек. 2025 г. в 17:51, Andrey Tarasevich <[email protected]>:
> > On 12/08/2025 4:41 AM PST Александр Поваляев <[email protected]>
> wrote:
> > This is how explicit conversion looks like - "subfunc((struct zzz const
> *
> > const * const)arr_of_ptr);".
> > Per me, it is awful and makes the code less readable.
>
> That's partially your fault, since you keep adding that redundant and
> nonsensical `const` at the end. Let me fix that for you:
>
> subfunc((struct zzz const * const *) arr_of_ptr);
>
> See? A lot more readable!
>
> Of course, typedef-ing your struct would've made the code even shorter.
>
> --
> Best regards,
> Andrey
>