in reply to Re: How to initialize all variables
in thread How to initialize all variables

I think you're being unreasonably insistent. Perl makes certain guarantees re initialization and I don't see a problem with relying on that. To my eye, explicit initialization often clutters more than it clarifies. For example, I prefer:

my $fred; # $fred contains undef my @jock; # @jock is empty
to the explicitly initialized:
my $fred = undef; my @jock = ();
Similarly, ANSI C guarantees that global/static variables are initialized to zero and I often take advantage of that by omitting explicit initialization, especially when initializing arrays (as I did, for example, in Re: Rosetta PGA-TRAM).

Replies are listed 'Best First'.
Re^3: How to initialize all variables
by Anonymous Monk on Sep 12, 2010 at 02:54 UTC
    I sure this will never happen to you or your code but what would happen if someone pass the code through a automate code translator ... say Perl 5 to Perl 6 or Fortran77 ... god knows. What would happen then? You don't know do you. It all depends on what the translator does, doesn't it? Or how the other language wants to initialize things. Since you did not implicitly initial your variables. I hope you remain blissfully unaware.

      what would happen if someone pass the code through a automate code translator ... say Perl 5 to Perl 6 or Fortran77 ... god knows. What would happen then?
      Given how much existing Perl 5 code relies on these initialization semantics, any Perl 5 translator that did not understand these semantics, and translate accordingly, would be pretty useless.

      Knowing the primary author of the upcoming official Perl 5 to Perl 6 translator, I doubt he'll have any difficulty with Perl 5's longstanding initialization semantics. :)

        Well! Since you know the primary author I guess you win this argument. Good for you.

      There is no way to protect from buggy translators.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.