----------------------------------------
> Date: Mon, 7 Jan 2008 01:14:40 -0800
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: Introducing Cobra
> 
> Gabriel Sechan wrote:
>> It is?  I've never heard that.  In fact, I frequently hear (and agree with) 
>> the exact opposite-  put every declaration at the top so that you can easily 
>> find the declarations of all variables.
> You are working with a different definition of "modern languages". That
> is thinking is still very strong in the C community, although even they
> stopped forcing that thinking with the advent of C99. The modern
> thinking is that you should declare a variable around when it is first
> used, so that the declaration is right by the code that actually uses it.

Yes, I've heard this before.  I've also heard it pretty much universally 
panned.  It makes code so much harder to read, when you have to search around 
for the type.  

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.

>>   As a bonus, you can read the variables used and their types at the 
>> begining.
> ...and as an extra bonus, you have almost no context for understanding
> each of their roles until you start reading. This means you have to
> remember what all the variables are and/or constantly refer back to them
> while reading the code, even if some of them may not yet be relevant.
> 
You have an odd definition of constantly.  Maybe once per variable, if its use 
in the code doesn't make it intuitively obvious and you don't remember it.  
More realisticly, once per function.  The benefits of knowing the data to be 
used up front outweight it by so far its laughable.  In fact, I find myself 
refering back to get a type far more in the embedded declaration style.


>> This is honestly the first time I've *ever* heard of it being considered bad 
>> style.
>>   
> Java, C++, C#, most scripting languages, etc....
> 

 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.
Gabe
_________________________________________________________________
Watch “Cause Effect,” a show about real people making a real difference.
http://im.live.com/Messenger/IM/MTV/?source=text_watchcause
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to