There's another factor, here, unfortunately: -w warnings.

I personally never use -w, unfortunately, because it warns about not only variables 
being used before they are first set (usually a good thing to warn about) but also the 
use of variables whose value is undef, which is a perfectly legitimate and 
time-honored tradition in perl.

However, anyone writing for modules that must compile and work well under -w, as most 
public modules should, has to worry about this problem since many people really want 
everything they write or use to run clean under -w.

Certainly this would apply to Doug's code and most public high-profile modules on 
CPAN, so that's the biggest reason why you see people doing "unnecessary" 
initializations.

We all hope, I think, that the new, more flexible approach to warnings in 5.6 will 
mitigate this situation in the coming years.

-chris

At 7:19 PM +0100 7/10/00, Matt Sergeant wrote:
>On Mon, 10 Jul 2000, Drew Taylor wrote:
>
>> Here's another topic I've had on my mind lately.
>> 
>> I currently try to initialize all vaiables in the definition (my $var =
>> ();) I've read where several I respect, Doug being one :-), initialize
>> variables. Then I've read posts of people comparing the op count from
>> initializtion vs. non-initialization where initialization creates a
>> sizable more percentage of calls.
>> 
>> So my question is: Is variable initialization necessary? Is being a
>> lexical enough? To date, I've played it safe. But if I don't have to...
>> then I won't.
>> 
>> Does anyone have good evidence either way?
>
>I doubt you'll find evidence, just some hand waving. If you know what
>you're doing, use lexicals and don't worry about initialization. If you
>don't know what you're doing, initialize.
>
>-- 
><Matt/>
>
>Fastnet Software Ltd. High Performance Web Specialists
>Providing mod_perl, XML, Sybase and Oracle solutions
>Email for training and consultancy availability.
>http://sergeant.org | AxKit: http://axkit.org


------------------------------------------------------------------------
Chris Thorman                                       (413) 473-0853 e-fax
------------------------------------------------------------------------

Reply via email to