in reply to Re^3: Perl Style: Is initializing variables considered taboo?
in thread Perl Style: Is initializing variables considered taboo?

> Unless is was used in module you called, or the previous iteration of the loop, or call to sub, or ...

...which describes "already initialized".

UPDATE:

IMHO your intention is to control the scope of a variable.

my is only one mean to achieve this, our, state, local are others.

Cheers Rolf

Replies are listed 'Best First'.
Re^5: Perl Style: Is initializing variables considered taboo?
by BrowserUk (Patriarch) on Aug 21, 2010 at 17:08 UTC
    .which describes "already initialized".

    In which case you need to reinitilise them.

    IMHO your intention is to control the scope of a variable.

    You're telling me what my [sic] intent was?

    My intent was to state that initialisation to undef is unnecessary when you use my. Nothing more and nothing less.

    As for you "scoping" missive:

    • our limits visibility, not scope.
    • state persists scope, not limits it.
    • local limits scope temporarially, but not reliably.

      If you localise a var, but then call some sub or method that uses it without localising it, you get screwed over.

    But quite why you feel the need to tell me (wrongly) about these things I don't understand, because I'm pretty sure that you're aware that I know they exist, and what they do. And they have no bearing on what I said.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      My intention is to have a consistent terminology,

      It doesn't worth it discussing things if everyone has his own vocabulary.

      Talking about our, state, local I disagree. The term "scope" can be characterized as dynamic OR static, it has compilation and runtime aspects.

      Just grep thru the perldocs.

      But since we both exactly know how they work I'll quit this discussion.

      Cheers Rolf

      PS: maybe worth a look http://perldoc.perl.org/perlglossary.html

        Talking about our, state, local I disagree.

        Then you are wrong!

        The term "scope" can be characterized as dynamic OR static, it has compilation and runtime aspects.

        True. But that has no affect on how those keywords affect scope.

        • our limits visibility, not scope.

          our only affects dynamically scoped variables. Their scope remains global, our just makes them visible within the current lexical context.

        • state persists scope, not limits it.

          It allows a lexical variable to retain its value beyond its lexical lifetime. It extends rather than restricts it.

        • local limits scope temporarially, but not reliably.

          If you localise a (dynamic) var, but then call some sub or method that uses it without localising it, you get screwed over.

        But since we both exactly know how they work

        Hm. Do you? It doesn't seem that way.

        I'll quit this discussion

        Good idea.