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)
On Thu, Jul 09, 2026 at 06:59:41 +0700, Robert Elz wrote:
> 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?
In all fairness, minor formatting choices _can_ have big impact.
The following is a true story. At an old job we hit a bug. We knew
for a fact that the bug was located in a relatively small fragment of
code. _5_ engineers took turns staring at that code for a couple of
_hours_ and couldn't see the bug. The code was something like this:
if (valgrind) {
// slow, so increase timeouts a lot
} if (some condition) {
// increase timeouts a bit
} else {
// ...
}
This is, btw, why I hate winged "else".
So just as
if (foo) {
...
} else if (bar) {
...
}
vs.
if (foo) {
...
}
else if (bar) {
...
}
is a minor formatting change that, as the story above shows, may have
non-trivial effect on readability, the choice of (index --> 0)
spelling may have a similar effect. Unfortunately, that spelling is
not just more explicit, but is also "cute", even terminally cute, and
it seems to cause massive cognitive dissonance when encountered by an
unsuspecting reader.
-uwe
Home |
Main Index |
Thread Index |
Old Index