Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Perl Style: Is initializing variables considered taboo?

by BrowserUk (Patriarch)
on Aug 21, 2010 at 16:38 UTC ( [id://856479]=note: print w/replies, xml ) Need Help??


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

Why you are restricting this behavior to my...? Every non-initialized variable is not defined.

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

They may start out as undef, but only for the first use.


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.

Replies are listed 'Best First'.
Re^4: Perl Style: Is initializing variables considered taboo?
by LanX (Saint) on Aug 21, 2010 at 16:42 UTC
    > 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

      .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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://856479]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-19 03:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found