in reply to Re^2: what is the meaning of ();
in thread what is the meaning of ();

Are you saying that following coding style documents is cargo-cult programming? I tend to think that one should follow coding guidelines, no matter how stupid. If they suck, change the guidelines or change your job.

I'm sure you meant that it could be cargo-cult OR it could be adherence to a 'no defaults' style guideline/preference. The only way to know for sure would be to ask the original programmer why he wrote the code that way.

Consider the following code:

my $foo = undef;

The initialization to undef totally unnecessary, but it does communicate an idea: $foo really should be undef, it's not just an oversight.

While I don't use either unnecessary initialization, I don't see them as harmful.

Despite my personal preferences, I can see why someone would choose to explicitly initialize ALL their variables. It's not a bad habit to be in.

I guess the main thing I am trying to say is, don't be in too much of a rush to call something cargo-cult. What we have here could be CC code or it could be the result of a decision based on some painful lessons.


TGI says moo

Replies are listed 'Best First'.
Re^4: what is the meaning of ();
by MidLifeXis (Monsignor) on Jul 27, 2008 at 02:01 UTC

    No, I was saying that it could be a rule carried over from another language without judging the appropriateness of the rule in the new language.

    If the rule, or use, or meme has a valid reason behind it, then it is not cargo-cult.

    --MidLifeXis

Re^4: what is the meaning of ();
by Yunus (Novice) on Jul 27, 2008 at 17:51 UTC
    Programming should follow some rule-of-thumb, and explicitly initializing variable is one of them (no matter what languages we use). For expert (and to ourselves), it is good as reminder. For beginner, it is good for learning. Let the(good) compiler do the optimization.

    "The giving hands is better than the one accepting" - Muslim's cleric