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
From:
Father Chrysostomos via RT
Date:
November 30, 2014 02:32
Subject:
[perl #123322] "our" has the same scoping rules as "my" or "state"
Message ID:
rt-4.0.18-27925-1417314716-1031.123322-15-0@perl.org
On Sat Nov 29 17:15:37 2014, ikegami@adaelis.com wrote:
> On Sat, Nov 29, 2014 at 7:14 PM, Father Chrysostomos via RT <
> perlbug-followup@perl.org> 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
https://rt.perl.org/Ticket/Display.html?id=123322

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About