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

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

Thread Next
From:
Father Chrysostomos via RT
Date:
November 29, 2014 04:33
Subject:
[perl #123322] "our" has the same scoping rules as "my" or "state"
Message ID:
rt-4.0.18-18620-1417235581-1938.123322-15-0@perl.org
On Fri Nov 28 20:32:00 2014, sprout wrote:
> On Fri Nov 28 15:34:12 2014, ikegami@adaelis.com wrote:
> >
> > This is a bug report for perl from ikegami@adaelis.com,
> > generated with the help of perlbug 1.40 running under perl 5.20.1.
> >
> >
> > -----------------------------------------------------------------
> > [Please describe your issue here]
> >
> >
> > $ perldoc -f our | grep 'same scoping'
> >             "our" has the same scoping rules as "my" or "state",
> > meaning that
> >
> > $ perl -Mstrict -E'say( ( our $y = "abc" ), $y )'
> > abcabc
> >
> > $ perl -Mstrict -E'say( ( my $y = "abc" ), $y )'
> > Global symbol "$y" requires explicit package name at -e line 1.
> > Execution of -e aborted due to compilation errors.
> >
> > Seems the docs aren't accurate.
> 
> There is code in pad.c to make ‘our’ cover the current statement (if
> there are no pad entries already under the same name in scope from
> previous statements), added in 929a0744021.  The relevant thread
> starts at <FC2E47BE-B781-11D7-BE4D-000A95A2734C@nanisky.com>.

(And, tangentially, it causes the pad to be searched linearly *twice*.  We should be able to make this a single search.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123322

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