Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^4: Examples fo Where "our" is really needed

by ihb (Deacon)
on May 06, 2005 at 01:24 UTC ( #454557=note: print w/replies, xml ) Need Help??


in reply to Re^3: Examples fo Where "our" is really needed
in thread Examples fo Where "our" is really needed

In Perl the word "our" does not declare a variable, but a private view of a public variable.

That's why I said "declare the same variable twice" and meant exactly the same as you do but with different words. Regardless how one choose to paint the issue I don't like to do the same thing twice if I don't have to or have a good reason not to. If I can't use regular ways of scoping access to a global then I can't, but if I can, as in my example above, I really prefer to not repeat myself. The day I refactor my code and/or mistype the name in one "repeated" our I might very well be hunting reasons for my uninitialized warnings instead of getting the help from the compiler I could've gotten. I'm unfortunately not just hypothesizing.

our has its uses, but I think that scattering out ours to tighten down the access scope for globals instead of create new scopes when that's possible/not inconvenient is an abuse rather than a use of our.

ihb

See perltoc if you don't know which perldoc to read!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-10-24 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?