public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Coding convention: use of `!x' vs. `! x'
@ 2000-09-22  0:29 Mark Mitchell
  2000-09-24 22:57 ` Geoff Keating
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Mitchell @ 2000-09-22  0:29 UTC (permalink / raw)
  To: gcc; +Cc: Gerald Pfeifer

I have contacted the people responsible for the GNU Coding Standards,
and they have indicated that there is no official GNU practice, and
that the issue is sufficiently minor that they do not think an
offical GNU standard is required.

However, I suggest that within GCC we use a consistent style going
forward, and that the style be `!x' rather than `! x'.  This is no big
deal, and it would be a waste of effort to change all uses of the
latter into the former, but going forward let's use the former style.

Gerald, as web page maintainer would you be willing to create a page
for coding standards used in GCC above and beyond those mandated by
the GNU Coding Standards?  The discussion we just had about using
all_lowercase names for macros that are front-ends for functions would
be another thing we could include on this page.  I'm sure more things
will come up in the future.

Thanks,

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22  0:29 Coding convention: use of `!x' vs. `! x' Mark Mitchell
@ 2000-09-24 22:57 ` Geoff Keating
  2000-09-24 23:43   ` Mark Mitchell
  0 siblings, 1 reply; 16+ messages in thread
From: Geoff Keating @ 2000-09-24 22:57 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: gcc

Mark Mitchell <mark@codesourcery.com> writes:

> I have contacted the people responsible for the GNU Coding Standards,
> and they have indicated that there is no official GNU practice, and
> that the issue is sufficiently minor that they do not think an
> offical GNU standard is required.
> 
> However, I suggest that within GCC we use a consistent style going
> forward, and that the style be `!x' rather than `! x'.  This is no big
> deal, and it would be a waste of effort to change all uses of the
> latter into the former, but going forward let's use the former style.

Would this apply to casts, also?

eg.  `((const foo *)a) + 1'  vs. `((const foo *) a) + 1)'
     `(const foo *)a + 1'  vs. `(const foo *) a + 1)'

-- 
- Geoffrey Keating <geoffk@cygnus.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-24 22:57 ` Geoff Keating
@ 2000-09-24 23:43   ` Mark Mitchell
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Mitchell @ 2000-09-24 23:43 UTC (permalink / raw)
  To: geoffk; +Cc: gcc

  Would this apply to casts, also?

  eg.  `((const foo *)a) + 1'  vs. `((const foo *) a) + 1)'
       `(const foo *)a + 1'  vs. `(const foo *) a + 1)'

Good question.  I just grepped for `xmalloc' in the GCC sources as
that is a good source of casts, and although both forms are used, the
`(X) Y' form is considerably more prevalent, so I think we should use
that form.

Thanks,

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re:  Coding convention: use of `!x' vs. `! x'
  2000-09-22  9:32 Richard Kenner
  2000-09-22  9:50 ` David Edelsohn
@ 2000-09-30  9:52 ` Mark Mitchell
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Mitchell @ 2000-09-30  9:52 UTC (permalink / raw)
  To: kenner; +Cc: gcc

>>>>> "Richard" == Richard Kenner <kenner@vlsi1.ultra.nyu.edu> writes:

    Richard> What about the other unary operators?  Should they have a
    Richard> blank, like the binary operators do, or no blank, like
    Richard> "!" now will?

I apologize for taking so long to reply.  Let's have no space there
either.

Thanks,

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
@ 2000-09-26  4:36 Jamie Lokier
  0 siblings, 0 replies; 16+ messages in thread
From: Jamie Lokier @ 2000-09-26  4:36 UTC (permalink / raw)
  To: gcc

On the subject of `!x' vs. `! x', I'd like to point out that different
operators have always been treated differently.

Does anyone write `a -> b' or `a . b'?  I didn't think so.

Does anyone write `a = * b;'?  Sometimes, but not all that often.

Casts.  Most of GCC and indeed GNU code generally includes a space
between the cast and the value: `(unsigned int) x'.

Unary operators that aren't casts: `++x', `x++', `*x', `!x' etc. seem to
be the norm.  However, `* x' and `- x' do appear from time to time.

Function calls include space between the function name and arguments,
including when the function is a pointer expression like `a->b (args)'.
When the function name is surrounded by parantheses, a space is still
included just as with cases: `(*fn) (args)'.

Binary expression operators are generally surrounded by whitespace.
However, `a->b', `a.b' and for C++, `a::b' seem to be the norm for
syntactic operators.

Occasionally in non-GCC code I see space used to indicate grouping:
`a + 2*b' for example.  I think it looks equally clear with or without
the spaces there, and for consistency I tend to write `a + 2 * b'.

enjoy,
-- Jamie

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-25 11:32       ` Phil Edwards
@ 2000-09-26  1:29         ` Andreas Schwab
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Schwab @ 2000-09-26  1:29 UTC (permalink / raw)
  To: Phil Edwards; +Cc: Akim Demaille, gcc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

Phil Edwards <pedwards@disaster.jaj.com> writes:

|> On Mon, Sep 25, 2000 at 11:08:42AM +0200, Akim Demaille wrote:
|> > 
|> > Would you say much of the problems are coming from the fact that the
|> > standards support things like
|> > 
|> >         ./configure
|> >         make prefix=/foo
|> > 
|> > ?  I'm personally strongly in favor of deprecating this practice, and
|> > support only
|> > 
|> >         ./configure --prefix
|> >         make
|> 
|> Well, but
|> 
|>    configure --prefix=/foo
|>    make
|>    make prefix=/bar install
|> 
|> needs to be supported.

Even better if it would support a DESTDIR prefix like in automake.

Andreas.

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-25  2:04     ` Akim Demaille
  2000-09-25  7:29       ` Mark Mitchell
@ 2000-09-25 11:32       ` Phil Edwards
  2000-09-26  1:29         ` Andreas Schwab
  1 sibling, 1 reply; 16+ messages in thread
From: Phil Edwards @ 2000-09-25 11:32 UTC (permalink / raw)
  To: Akim Demaille; +Cc: gcc

On Mon, Sep 25, 2000 at 11:08:42AM +0200, Akim Demaille wrote:
> 
> Would you say much of the problems are coming from the fact that the
> standards support things like
> 
>         ./configure
>         make prefix=/foo
> 
> ?  I'm personally strongly in favor of deprecating this practice, and
> support only
> 
>         ./configure --prefix
>         make

Well, but

   configure --prefix=/foo
   make
   make prefix=/bar install

needs to be supported.


Phil

-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-25  2:04     ` Akim Demaille
@ 2000-09-25  7:29       ` Mark Mitchell
  2000-09-25 11:32       ` Phil Edwards
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Mitchell @ 2000-09-25  7:29 UTC (permalink / raw)
  To: akim; +Cc: gcc

>>>>> "Akim" == Akim Demaille <akim@epita.fr> writes:

    Akim> Would you say much of the problems are coming from the fact
    Akim> that the standards support things like

    Akim>         ./configure make prefix=/foo

No -- but I don't doubt that there are problems there.  I was merely
trying to avoid having to pull in so much stuff from target-dependent
Makefile fragments at make-time -- I wanted to do it at configure-time.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22 21:44   ` Mark Mitchell
@ 2000-09-25  2:04     ` Akim Demaille
  2000-09-25  7:29       ` Mark Mitchell
  2000-09-25 11:32       ` Phil Edwards
  0 siblings, 2 replies; 16+ messages in thread
From: Akim Demaille @ 2000-09-25  2:04 UTC (permalink / raw)
  To: gcc

>>>>> "Mark" == Mark Mitchell <mark@codesourcery.com> writes:

>>>>> "Tim" == Tim Josling <tej@melbpc.org.au> writes:
Tim> Before adding new standards I think it would be better to have
Tim> the existing standards followed more closely eg comments and
Tim> meaningful variable names. At present these are the major hurdles
Tim> in front of anyone wanting to help with GCC. In particular the
Tim> configure/make files are a major 'swamp of no return'.

Mark> I don't think it's either/or.  I would love to see the Makefiles
Mark> improved.  I actually looked at this stuff a few months back,
Mark> and couldn't quite do what I wanted to do -- which was to move a
Mark> lot more stuff to configure time, instead of Makefile evaluation
Mark> time.

Would you say much of the problems are coming from the fact that the
standards support things like

        ./configure
        make prefix=/foo

?  I'm personally strongly in favor of deprecating this practice, and
support only

        ./configure --prefix
        make

Your last sentence seems to indicate you met that frontier.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22 17:00 ` Tim Josling
  2000-09-22 18:21   ` Stan Shebs
@ 2000-09-22 21:44   ` Mark Mitchell
  2000-09-25  2:04     ` Akim Demaille
  1 sibling, 1 reply; 16+ messages in thread
From: Mark Mitchell @ 2000-09-22 21:44 UTC (permalink / raw)
  To: tej; +Cc: gcc

>>>>> "Tim" == Tim Josling <tej@melbpc.org.au> writes:

    Tim> Before adding new standards I think it would be better to
    Tim> have the existing standards followed more closely eg comments
    Tim> and meaningful variable names. At present these are the major
    Tim> hurdles in front of anyone wanting to help with GCC. In
    Tim> particular the configure/make files are a major 'swamp of no
    Tim> return'.

I don't think it's either/or.  I would love to see the Makefiles
improved.  I actually looked at this stuff a few months back, and
couldn't quite do what I wanted to do -- which was to move a lot more
stuff to configure time, instead of Makefile evaluation time.

    Tim> Maybe it is deliberable to stop people who don't know what
    Tim> they are doing from getting involved.

It's not.  It is unfortunate, though, that things got to the state
they're in.

    Tim> Are there any programs to test for FSF standards compliance,
    Tim> realizing that full checking is not possible, you could check
    Tim> quite a lot.

I don't know of any such programs.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22 17:00 ` Tim Josling
@ 2000-09-22 18:21   ` Stan Shebs
  2000-09-22 21:44   ` Mark Mitchell
  1 sibling, 0 replies; 16+ messages in thread
From: Stan Shebs @ 2000-09-22 18:21 UTC (permalink / raw)
  To: Tim Josling; +Cc: gcc

Tim Josling wrote:
> 
> Before adding new standards I think it would be better to have
> the existing standards followed more closely eg comments and
> meaningful variable names. At present these are the major hurdles
> in front of anyone wanting to help with GCC. In particular the
> configure/make files are a major 'swamp of no return'.

Unfortunately almost everything in configure/make is there for
a reason, as people have discovered when they got ambitious
and tried to remove things, and the constraints are pretty
severe - must need only /bin/sh, vanilla make, etc.  Even so,
the system is complicated for everybody, even those who've
been working with it for a long time, and we would certainly
welcome changes that simplify things.

> Maybe it is deliberable to stop people who don't know what they
> are doing from getting involved.

Heh heh, I don't know any GNU developers that are quite that
clever!  We all have a common interest in making things as
simple as possible.

> Are there any programs to test for FSF standards compliance,
> realizing that full checking is not possible, you could check
> quite a lot.

GNU indent followed by diff is pretty useful, any differences
point to variations from the standard.  People should be aware
that the GNU standards are actually recommendations rather than
ironclad rules, and it's up to individual projects to decide
how closely to adhere to them, and which way to go when the
standard does not make a single specific recommendation.  For
instance, GDB has policies (such as the use of ISO C) that are
different from GCC's policies.

Stan
shebs@apple.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Coding convention: use of `!x' vs. `! x'
       [not found] <969652582.12981.ezmlm@gcc.gnu.org>
@ 2000-09-22 17:00 ` Tim Josling
  2000-09-22 18:21   ` Stan Shebs
  2000-09-22 21:44   ` Mark Mitchell
  0 siblings, 2 replies; 16+ messages in thread
From: Tim Josling @ 2000-09-22 17:00 UTC (permalink / raw)
  To: gcc

Before adding new standards I think it would be better to have
the existing standards followed more closely eg comments and
meaningful variable names. At present these are the major hurdles
in front of anyone wanting to help with GCC. In particular the
configure/make files are a major 'swamp of no return'.

Maybe it is deliberable to stop people who don't know what they
are doing from getting involved. 

Are there any programs to test for FSF standards compliance,
realizing that full checking is not possible, you could check
quite a lot.

Tim Josling


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22  9:50 ` David Edelsohn
@ 2000-09-22 10:22   ` Tim Hollebeek
  2000-09-22 10:22   ` Gabriel Dos Reis
  1 sibling, 0 replies; 16+ messages in thread
From: Tim Hollebeek @ 2000-09-22 10:22 UTC (permalink / raw)
  To: gcc

David Edelsohn writes ...
> 
> Richard> What about the other unary operators?  Should they have a blank, like the
> Richard> binary operators do, or no blank, like "!" now will?

One practical advantage of using "!x" (and similar for all other unary
operators) is that it is visually consistent with the C precedence
rules.

 5 - ~ x + 1 // less clear
 5 - ~x + 1  // better

// more realistic example
 y + * x + 1
 y + *x + 1

-Tim


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22  9:50 ` David Edelsohn
  2000-09-22 10:22   ` Tim Hollebeek
@ 2000-09-22 10:22   ` Gabriel Dos Reis
  1 sibling, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2000-09-22 10:22 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Richard Kenner, mark, gcc

David Edelsohn <dje@watson.ibm.com> writes:

[...]

| ...  To maintain symmetry with the rest of the style, I
| think that unary operators should have spaces, contrary to Mark's
| proposal.

Actually, there is no symmetry between unary operators and binary
operators.  My preference is for "!x" or "~x".

-- Gaby
CodeSourcery, LLC                             http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Coding convention: use of `!x' vs. `! x'
  2000-09-22  9:32 Richard Kenner
@ 2000-09-22  9:50 ` David Edelsohn
  2000-09-22 10:22   ` Tim Hollebeek
  2000-09-22 10:22   ` Gabriel Dos Reis
  2000-09-30  9:52 ` Mark Mitchell
  1 sibling, 2 replies; 16+ messages in thread
From: David Edelsohn @ 2000-09-22  9:50 UTC (permalink / raw)
  To: Richard Kenner; +Cc: mark, gcc

>>>>> Richard Kenner writes:

> However, I suggest that within GCC we use a consistent style going
> forward, and that the style be `!x' rather than `! x'.  This is no big
> deal, and it would be a waste of effort to change all uses of the
> latter into the former, but going forward let's use the former style.

Richard> What about the other unary operators?  Should they have a blank, like the
Richard> binary operators do, or no blank, like "!" now will?

	There may not be any definition in the GNU Coding Standards, but I
always have seen spaces around unary operators and that has been the
standard (I guess informal) that I was told.  I am not commenting on
whether I like it or not, but I disagree with making this style change.
If we now have `!x' and `~x' scattered throughout the code, I think it is
because we have not been as diligent about maintaining the original style
as we used to be.  To maintain symmetry with the rest of the style, I
think that unary operators should have spaces, contrary to Mark's
proposal.

David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re:  Coding convention: use of `!x' vs. `! x'
@ 2000-09-22  9:32 Richard Kenner
  2000-09-22  9:50 ` David Edelsohn
  2000-09-30  9:52 ` Mark Mitchell
  0 siblings, 2 replies; 16+ messages in thread
From: Richard Kenner @ 2000-09-22  9:32 UTC (permalink / raw)
  To: mark; +Cc: gcc

    However, I suggest that within GCC we use a consistent style going
    forward, and that the style be `!x' rather than `! x'.  This is no big
    deal, and it would be a waste of effort to change all uses of the
    latter into the former, but going forward let's use the former style.

What about the other unary operators?  Should they have a blank, like the
binary operators do, or no blank, like "!" now will?

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2000-09-30  9:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-22  0:29 Coding convention: use of `!x' vs. `! x' Mark Mitchell
2000-09-24 22:57 ` Geoff Keating
2000-09-24 23:43   ` Mark Mitchell
2000-09-22  9:32 Richard Kenner
2000-09-22  9:50 ` David Edelsohn
2000-09-22 10:22   ` Tim Hollebeek
2000-09-22 10:22   ` Gabriel Dos Reis
2000-09-30  9:52 ` Mark Mitchell
     [not found] <969652582.12981.ezmlm@gcc.gnu.org>
2000-09-22 17:00 ` Tim Josling
2000-09-22 18:21   ` Stan Shebs
2000-09-22 21:44   ` Mark Mitchell
2000-09-25  2:04     ` Akim Demaille
2000-09-25  7:29       ` Mark Mitchell
2000-09-25 11:32       ` Phil Edwards
2000-09-26  1:29         ` Andreas Schwab
2000-09-26  4:36 Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).