Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG our() 5.005_63] Lexical scoping problems. #1069

Closed
p5pRT opened this issue Jan 23, 2000 · 3 comments
Closed

[BUG our() 5.005_63] Lexical scoping problems. #1069

p5pRT opened this issue Jan 23, 2000 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 23, 2000

Migrated from rt.perl.org#2021 (status was 'resolved')

Searchable as RT2021$

@p5pRT
Copy link
Author

p5pRT commented Jan 23, 2000

From @schwern

our $a = "Outer";
{
  our $a = "Inner";
  print "$a\n";
}
print "$a\n";

$a is "Inner" in both places. If I understand how our() works, its
supposed to have the same scoping rules as my(). I would expect
"Inner" and then "Outer", same as my().

Next, our() doesn't appear to localize in a loop conditional​:

our $a = "Outer";
for (our $a = 1; $a < 2; $a++) {
  print "$a\n";
}
print "$a\n";

$a is 3, not "Outer" after the for loop. I presume the two bugs are
related.

However, this -does- work as expected.

our $a = "Outer";
for our $a (1, 2) {
  print "$a\n";
}
print "$a\n";

$a is 'Outer' after the for loop.

--

Michael G Schwern schwern@​pobox.com
  http​://www.pobox.com/~schwern
  /(?​:(?​:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

@p5pRT
Copy link
Author

p5pRT commented Apr 23, 2003

From @iabyn

(Just closing old bugs :-)

Your bug report was labouring under the mis-apprehension that 'our'
localises stuff. Since it doesn't, its not-a-bug!
The
  for our $x (...)
appeared to localise only because for itself localises, ie
  for $x (...)
works just as well.

Regards,
Dave M.

@p5pRT
Copy link
Author

p5pRT commented Apr 23, 2003

@iabyn - Status changed from 'stalled' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant