-
Notifications
You must be signed in to change notification settings - Fork 542
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
'package' docs say 'our' is lexical (?) #12366
Comments
From @jimavThis is just a question, although it probably indicates that the perlfunc says: I'm confused about that last bit which says "our" creates a lexical. Under what circumstances is 'our' not affected by the current package? Flags: Site configuration information for perl 5.14.2: Configured by Debian Project at Fri Aug 10 21:43:06 UTC 2012. Summary of my perl5 (revision 5 version 14 subversion 2) configuration: Locally applied patches: @INC for perl 5.14.2: Environment for perl 5.14.2: |
From @rjbspackage X; The name $X is lexically scoped and refers to the package variable $X in the package in which it |
The RT System itself - Status changed from 'new' to 'open' |
From @apAlso, use strict; dies with an undeclared variable error. |
From @ikegamiIt is correct. C<our> creates a lexical variable which is aliased to a - Eric |
From @cpansproutOn Thu Aug 30 16:04:51 2012, ikegami@adaelis.com wrote:
And the documentation for ‘our’ was expanded in bleadperl recently, when -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
From perl-diddler@tlinx.orgFather Chrysostomos via RT wrote:
Was it also mentioned that if they want package variables, they need to use |
From mail@steffen-mueller.netOn 09/04/2012 06:00 AM, Linda W wrote:
Please read what ikegami wrote. 'our' creates a lexical alias to a If you want package variables, declare that you intend to use it using Thus, the documentation is correct since the effect of 'our' is lexical. --Steffen |
From @ap* Linda W <perl-diddler@tlinx.org> [2012-09-04 06:05]:
You are utterly confused. |
From @dmcbrideOn Tuesday September 4 2012 4:28:22 PM Aristotle Pagaltzis wrote:
To be fair, when I first read about "our", it was being billed, probably Basically, the impression I got is that it's a drop-in replacement for use So, when people get into those rare cases, I have to admit understanding their Now, does the documentation need improving? Not necessarily. I think there The docs now have been modified many times since our was introduced due to this But, really, I know, now, that I'm operating with some really old knowledge. "The vars pragma is obsolete because C<our> accomplishes the same goals, and |
From perl-diddler@tlinx.orgSteffen Mueller wrote:
Right. But if you only want a package scoped package variable, That's the point. "use vars" give you access to "package-scoped"
You didn't address the case of using a variable that goes out of
I, wasn't saying it was -- I was emphasizing that to get package-scoped Too many people make the mistake of believing that 'our' defines That confusion and the lack of the clear function of 'use vars' (to |
From @doyOn Tue, Sep 04, 2012 at 10:31:25AM -0700, Linda W wrote:
The reason it works like this is because a lexically scoped alias to the -doy |
From perl-diddler@tlinx.orgJesse Luehrs wrote:
I disagree -- If I want a lexically scoped variable, I put my package {package foobar; If I explicitly use packages without the braces, -- which I might Without braces 'our' gives you a file-scoped var in whatever |
From @doyOn Tue, Sep 04, 2012 at 10:52:38AM -0700, Linda W wrote:
I wonder if the right answer here is to make using an 'our' variable in -doy |
From @ikegamiOn Tue, Sep 4, 2012 at 1:31 PM, Linda W <perl-diddler@tlinx.org> wrote:
Nothing provides package-scoped variables. Package variables are global
No, both "use vars" and "our" provides access to (the same) package |
From perl-diddler@tlinx.orgEric Brine wrote:
package two; Clearly you are either don't know what you are taking about or are |
From @rjbs* Linda W <perl-diddler@tlinx.org> [2012-09-04T14:14:55]
Linda, you are mistaken.
This is not the right program to demonstrate the truth of what Eric said. ~$ perl -e ' "use vars" lets you use the name $b to refer to $one::b without qualification The variable's accessibility is still global. Only the scope and availability
Tread carefully. -- |
From @LeontOn Tue, Sep 4, 2012 at 7:52 PM, Linda W <perl-diddler@tlinx.org> wrote:
He said almost always, not always. You happen to have a style that is Within your style what you're asking for makes sense, but the Leon |
From @dmcbrideOn Tuesday September 4 2012 11:14:55 AM Linda W wrote:
Linda, have you considered taking your questions to a forum better suited for
This doesn't prove what you think it does. Eric is correct, they are This might be a bit more clear: $ perl -Mstrict -Mwarnings -E ' This might be a bit more clear: first we enable strict and warnings so you can We then set it. Without the use vars, $two = 3 would fail, but without We spit it out, just so we see it. Then we create the lexical alias and say it. Unsurprisingly, it's the same. We then switch packages and say it again. Due to the lexical scope here, we
Not clear at all. What's clear is that you didn't understand Eric's I would really appreciate it if you could take your "I don't understand Perl" Thank you. |
From @ikegamiOn Tue, Sep 4, 2012 at 2:14 PM, Linda W <perl-diddler@tlinx.org> wrote:
You didn't print The $b of <<use vars>>. That's a different $b you printed. |
From @ikegamiOn Tue, Sep 4, 2012 at 2:40 PM, Eric Brine <ikegami@adaelis.com> wrote:
perl -e ' package two; |
From @ikegamiIgnore my last message. Tried to convert her code into something that made perl -e' perl -e' |
From @ap* Darin McBride <dmcbride@cpan.org> [2012-09-04 18:30]:
It is not a matter of fairness. I mind not her confusion but the fact |
From perl-diddler@tlinx.orgEric Brine wrote:
My code didn't made sense to you, as I may have used some uncommon concepts #!/usr/bin/perl -l package one; 9) two-b=our Note in package two when we print $b, we see our -- closing the scope, we see package one's be is still 'var'. using a package-one scoped assignment to "our $b", it now gets the value The above shows the package scoped nature of "use vars"; I don't see any bugs above -- just documentation needed to |
From @doyOn Tue, Sep 04, 2012 at 04:06:19PM -0700, Linda W wrote:
But again, as has been explained several times over at this point, this package P1; package P2; package P1; prints a = '1' 'use vars' has nothing at all to do with scoping. -doy |
From perl-diddler@tlinx.orgJesse Luehrs wrote:
It is valid within package scoping. How is that "nothing at all to When you declare package P2, the namespace of package P1 goes "out of How is that not scoping by namespace? |
From @doyOn Tue, Sep 04, 2012 at 04:26:02PM -0700, Linda W wrote:
Try running that without the 'use vars' statement - you'll get the exact -doy |
From @ikegamiOn Tue, Sep 4, 2012 at 7:06 PM, Linda W <perl-diddler@tlinx.org> wrote:
Every time you reply to me, you say I said things you didn't Stop being It's a clear demosntration that our variables are lexical, but you were |
From @jimavI am the original poster of this bug. Thank you to everyone who has contributed. Thank you very much. -Jim Avera |
From perl-diddler@tlinx.orgEric Brine wrote:
Just because I call you on your putting words in my mouth, I'm a jerk?
My point was that the vars used by "use vars" do not behave the same way As someone else points out 'use vars' permit you to use They only allow you to access vars in the package .. not by braced-scope. They ARE the same variables... I *hoped* and *assumed* they were (though And by scoping I mean use vars allows you to access package vars in |
Migrated from rt.perl.org#114674 (status was 'resolved')
Searchable as RT114674$
The text was updated successfully, but these errors were encountered: