Source-Changes-D archive

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

Re: The --> "operator" (was: Re: CVS commit: src/sys/uvm)



    Date:        Wed, 8 Jul 2026 15:31:01 +0000
    From:        Taylor R Campbell <riastradh%NetBSD.org@localhost>
    Message-ID:  <20260708153102.C64DD84DA8%mail.netbsd.org@localhost>


  | I can tell you in a second _one_ of them is definitely correct, and
  | for _every other one_ it'll take me at least a few seconds if not a
  | few minutes to think about.

Really?

  | 	for (i = N; i --> 0;) { ... i ... }

That one, which is the one you (claim to) prefer, and

  | 	for (i = N; i-- > 0;} { ... i ... }

this one, which is in KNF (ignoring the statement part), differ by
exactly the positioning of one (unnecessary) space.

	for (i=N;i-->0;} { ... i ...}

is just the same, compressed a bit (I am not suggesting that be used).

You're really unable to see that these 3 all do the exact same thing in more
than about a millisecond?

And KNF does say to surround binary operators (of which '>' is one)
with spaces (--> isn't an operator, it is two).   But KNF's stance on
that is kind of meaningless, as no-one surrounds -> . or [ with spaces,
and yet all are binary operators in C.

kre

ps: while C has not had a habit of inventing new operators (the # and ##
preprocessor operators are the only ones I can think of) in general it
is unwise to run operators into each other, as if someone should decide
to invent a --> operator, and it doesn't do what the two operators it
now represents do, then any use of that would break, whereas -- > never
will.




Home | Main Index | Thread Index | Old Index