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

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

Thread Previous | Thread Next
Father Chrysostomos via RT
November 30, 2014 02:32
[perl #123322] "our" has the same scoping rules as "my" or "state"
Message ID:
On Sat Nov 29 17:15:37 2014, wrote:
> 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.

At least the implementation and the docs will be consistent with each other.

> But if we want to document the current behaviour,

Which is a good question.  I’m not sure we can change the behaviour without breaking things.  And I’m not sure forbidding unqualified vars in the same statement as ‘our’ is going to help anyone.

> how does the following
> sound?
> 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
> name.
> 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.

Sounds fine to me.


Father Chrysostomos

via perlbug:  queue: perl5 status: open

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