develooper Front page | perl.perl5.porters | Postings from November 2014

Re: [perl #123322] "our" has the same scoping rules as "my" or "state"

Thread Previous | Thread Next
Eric Brine
November 30, 2014 01:15
Re: [perl #123322] "our" has the same scoping rules as "my" or "state"
Message ID:
On Sat, Nov 29, 2014 at 7:14 PM, Father Chrysostomos via RT <> wrote:

> > The linked thread explains that introducing the wackiness was
> > necessary because it was a maintenance release. But that's done. I just
> > mentioned the docs were inaccurate, but some consistency (one way or
> > another) would be nice.
> A doc patch would be nice. :-)  (I would say ‘patches welcome’, but I have
> never seen a patch welcome anyone.)

Changing the docs isn't going to bring consistency.

But if we want to document the current behaviour, how does the following

Like "my" and "state", "our" is only visible within a lexical scope. Unlike
"my" and "state", which both declare new (lexical) variables, "our" only
creates an alias to an existing variable: a package variable of the same

When the alias becomes available depends on whether an existing "my",
"state" or "our" with the same name exists in the current scope. If one
does, the alias becomes available at the beginning of the next statement.
Otherwise, it becomes available immediately.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About