Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation

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

 



Miles Bader wrote:
Christoph Hellwig <[email protected]> writes:

But serious, having to look all over the source instead of just a block
beginning decreases code readability a lot.


My experience is quite the opposite.

Being forced to put declarations at the beginning of the block in
practice means that people simply separate declarations from the first
assignment.  That uglifies and bloats the code, and seems to often cause
bugs as well (because people seem to often not pay attention to what
happens to a variable between the declaration and first assignment;
having it simply _not exist_ before the first assignment helps quite a
bit).


If your blocks are so big that you lose track of variables like
this... then it is too big and/or complex.

And the argument about having it simply _not exist_ before the
first assignment isn't convincing to me, because you cannot
undeclare variables after you finish with them (do you also see
code where people cause bugs by forgetting about the variable after
its last use?).

IMO, the system of declaring all variables at the top of the block
and they all disappear at the end is nice and symmetric... although
I probably agree with Linus on the 'for (int i = 0;' feature.

Nick

--
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux