Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Mar 2009 07:03:49 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        avg@FreeBSD.org
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, christoph.mallon@gmx.de, src-committers@FreeBSD.org, marius@alchemy.franken.de
Subject:   Re: svn commit: r190098 - in head/sys/sparc64: fhc sparc64
Message-ID:  <20090322.070349.195750067.imp@bsdimp.com>
In-Reply-To: <49C5F88C.3070600@freebsd.org>
References:  <49C5737F.1050902@gmx.de> <20090321.175756.-434257642.imp@bsdimp.com> <49C5F88C.3070600@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <49C5F88C.3070600@freebsd.org>
            Andriy Gapon <avg@freebsd.org> writes:
: on 22/03/2009 01:57 M. Warner Losh said the following:
: > I'll point out that style(9) doesn't say use as few local variables as
: > possible...  That part is completely unspecified.
: 
: But it does say:
: Do not put declarations inside blocks unless the routine is unusually
: complicated.

Yea, so?  Just put them at the top of the function where they belong
and don't worry about it.  Christoph has a long reason why this isn't bad.

: "unusually complicated" is, of course, a very subjective measure.
: But still this guideline contradicts typical guidelines for C and its
: offspring which name we do not say to declare variables as close to
: their first usage as possible.

thousands of lines is unusually complicated.

: E.g. you can have a simple 3 line block where you need a local variable
: but that block is located 50 lines from start of an enclosing function.
: Very convenient when you need to quickly glance the variable's type (not).

No you don't.  There's absolutely nothing wrong with putting them at
the top.  In fact, it is simpler, really, than having to go hunting
for dozens of different declarations.  As someone who has spent a lot
of time looking at code, the time wasted looking for these damn-fool
things really adds up.

The original point is valid: the code changes obfuscated perfectly
readable code for no gain in the object code.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090322.070349.195750067.imp>