----------------------------------------
> Date: Sun, 6 Jan 2008 17:29:12 -0800
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: Introducing Cobra
> 
> On Sun, Jan 06, 2008 at 05:11:01PM -0800, SJS wrote:
> 
>>Then again, putting all the variable declarations at the top of the
>>method/function gives you much of what you want.
>>
>>function name( args ... ) {
>>   LongArduousType foo; 
>>     . . .
>>   foo = new LongArduousType(...);
> 
> This is considered bad style in most modern languages.  In fact, it is
> forbidden in some.  The idea isn't to move the initialization up to the
> top, but to move the variable declaration down to where it is first
> assigned.  You don't ever declare variables without giving them their
> initial value.

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.  As a bonus, you can read the variables used 
and their types at the begining.  Typically, if I know what you're going to be 
using and the name of the function, I can guess how you're going to do 
something before you do it.  It makes the code far more readable.  The only 
real exception is index variables, like loop counters.

This is honestly the first time I've *ever* heard of it being considered bad 
style.

Gabe
_________________________________________________________________
Put your friends on the big screen with Windows Vista® + Windows Live™.
http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_012008
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to