[Shootout-list] LOC
Brian Hurt
bhurt@spnz.org
Sat, 30 Apr 2005 22:18:53 -0500 (CDT)
Having been around this rollercoaster ride before...
On Sun, 1 May 2005, Jon Harrop wrote:
> For example, instead of writing:
>
> if (i == 0)
> {
> j += 1;
> }
>
> I'd write:
>
> if (i == 0) ++j;
In my day-to-day C coding, I prefer the former to the latter. It makes it
much easier to slip in debugging statements, like:
if (i == 0)
{
printf("Hey, i==0!\n");
j += 1;
}
It also prevents errors of the form:
if (x == 7)
if (i == 0) j += 1;
else
...
But that's me.
> If the counter argument is that LOC is trying to measure the amount of typing
> then shouldn't we be measuring bytes instead of lines?
Because then tabbing becomes important. The problem with non-space bytes
is that variable names become important. Although non-space bytes
wouldn't be a bad measure (and fairly easy to implement).
> in OCaml. However, many programs (such as OCaml's harmonic) split definitions
> across multiple lines, which is unusual in OCaml programming. I suspect this
> is simply a case of asking authors to change their coding style.
Especially in Ocaml's case, where:
let x, y = 1, foo x in
means something different than:
let x = 1
and y = foo x
in
Specifically, in the former, a tuple is actually allocated and then
pattern matched against.
Brian