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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Something that seems to be missed every time this discussion is referenced is that the main purpose of our is not to replace use vars, but to serve as a syntactic peg upon which lexically scoped traits can be hung. The purpose of our is to provide a lexically scoped view of a global variable. The variable itself might not be constant, for instance, but I might want to declare it that way for the sake of my own discipline. Beyond that, various forms of allomorphism will only get more important as Perl 6 allows more type and trait declarations within variable and subroutine declarations. But even leaving allomorphism out of it, traits are becoming much more important in Perl 6. For instance, exported variables in Perl 6 are simply marked with an "is export" trait rather having to duplicate their names in an @EXPORT_OK list somewhere.

The secondary reason for having a lexically scoped declaration is to limit your exposure to accidental use of the variable. But really, that's just another aspect of controlling the "view", or non-view, in this case.

I doubt we'll all ever see eye-to-eye on the subject of globals, but at least grant me the privilege of pointing out that, at least in my mind, the feature was added more to future-proof the declaration syntax than out of reaction to use vars. I freely admit that our is of marginal benefit in Perl 5, but I was already thinking ahead to Perl 6 at that point, even if Perl 6 hadn't been named yet. :-)

In reply to Re: Why is 'our' good? by TimToady
in thread Why is 'our' good? by tilly

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2023-02-05 13:44 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (31 votes). Check out past polls.