Guru-nizing printing of types

Carlo Wood carlo@runaway.xs4all.nl
Mon Nov 15 06:58:00 GMT 1999


Ack, this answer JUST cross a third request from me to get feed back.

On Mon, Nov 15, 1999 at 12:23:36AM -0800, Mark Mitchell wrote:
> 
> Carlo --
> 
>   Thanks for your patch.  I'm not sure we want to do this, though.
> 
>   Whether to say `const int*' or `int const*' is a "religious issue";
> there are good arguments for both styles.  I'm not sure why we should
> change.

I've given arguments for the last style, but I can't think of any for
the second style.  Most notably, it is very confusing to get an error
message stating:

....: in function void foo(const TYPE) [ with TYPE = char * ]

when that really means `foo(char* const)' !

Don't you think that therefore a change of style has a good reason?
Please?

>   
>   Ideally, we would say whatever the user is most used to, or whatever
> was used in the code in question.  I guess I don't see why I wouldn't
> accept a patch to add a flag to switch between the two styles, but I
> think we should keep the current style as the default.
> 
> --
> Mark Mitchell                   mark@codesourcery.com
> CodeSourcery, LLC               http://www.codesourcery.com

Anyway, if you don't want to use the `int const*' style as default
then there isn't much I can do.  But,... how about using the
`int* func(const char*);' style as default instead of
`int *func(const char *)'?

I think that the fact that this is the style used in ANSI/ISO C++
standard, is being used as style by Bjarne Stroustrup in
"The C++ programming language" and is advocated (and used) by
the Cygnus team working on the new libstdc++ IS a good argument.

I know that it is not the style used for gcc itself, but don't
you think that it IS a better style to put the '*' and '&'
against the type rather then against the function or variable?
(thus, no space between the type and the '*' or '&').

I am willing to adjust my patch so at least this part becomes
the default style :/

Please consider,

Carlo Wood

PS  I am glad that you wouldn't disagree with a new option,
    but my `mission' is to make gcc set an example for newbie
    programmers who haven't choosen a style of there own yet.
    Therefore I think it must be the DEFAULT behaviour in
    order to meet my goal.
PS2 Don't think I am biased please.  I've been using the
    style `const int *p;' for 10 years, and only switched
    very recently to the new style, after I read the arguments
    of the libstdc++ team and gave things a new thought.
    It is a total new style for me, but only two days after
    switching I already couldn't understand how I EVER could
    have been using the other style!


More information about the Gcc-patches mailing list