On Mon, Jan 07, 2008 at 03:35:41AM -0600, Gabriel Sechan wrote:

There's also a difference between bad style and a difference of opinion-
I've heard people arguing (wrongly) that declare at use is better, I've
never heard declare at top considered bad.

I'll see if I can dig up the reference, but I'm fairly sure the source of
this is Bertrand Meyer.

99% of the C++ and Java code I've read, and 100% of the good C++ and
Java, rarely if ever makes non top of block declarations.   This isn't
even an exageration-  I honestly can't think of a piece of code written
the other way that wasn't a buggy piece of shit.

We're definitely looking at different bodies of code.  The Mono source
declares variables at first use.

However, I think more indiciative of better style is that there just aren't
very many places where it makes any difference.  There aren't a lot of
large functions with a bunch of variables in them.  But they are quite
consistent about declaring variables where the first value is.

I don't have a lot of C++ or Java code, but in what I do have, I can't find
a single instance of a variable declared not at the point of it's first
value.

Dave

--
KPLUG-LPSG@kernel-panic.org
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to