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
perlfunc/our contradicts itself #8019
Comments
From @schwernperlfunc/our sez: The "our" declaration has no semantic effect unless "use strict vars" is Ok, so that means any program should work the same with or without the our $foo = 42; # or just $foo 42 Except its not true. perlfunc/our goes on to contradict itself in the An "our" declaration declares a global variable that will be Which means: package Bar; acts different from package Bar; strict or not. I think the thing to do is to reword the first statement such that it no When C<use strict vars> is in effect, the C<our> declaration lets you -- |
From @schwernperlfunc.pod.patch--- pod/perlfunc.pod 2005/07/13 21:05:44 1.1
+++ pod/perlfunc.pod 2005/07/13 21:06:18
@@ -3242,15 +3242,14 @@
=item our TYPE EXPR : ATTRS
-An C<our> declares the listed variables to be valid globals within
-the enclosing block, file, or C<eval>. That is, it has the same
-scoping rules as a "my" declaration, but does not create a local
-variable. If more than one value is listed, the list must be placed
-in parentheses. The C<our> declaration has no semantic effect unless
-"use strict vars" is in effect, in which case it lets you use the
-declared global variable without qualifying it with a package name.
-(But only within the lexical scope of the C<our> declaration. In this
-it differs from "use vars", which is package scoped.)
+An C<our> declares the listed variables to be valid globals within the
+enclosing block, file, or C<eval>. That is, it has the same scoping
+rules as a "my" declaration, but does not create a local variable. If
+more than one value is listed, the list must be placed in parentheses.
+When C<use strict vars> is in effect, the C<our> declaration lets you
+use the declared global variable without qualifying it with a package
+name. (But only within the lexical scope of the C<our> declaration.
+In this it differs from "use vars", which is package scoped.)
An C<our> declaration declares a global variable that will be visible
across its entire lexical scope, even across package boundaries. The
|
From @ysthOn Wed, Jul 13, 2005 at 02:08:07PM -0700, Michael G Schwern wrote:
Wording looks good, but I'd prefer to see C<use strict 'vars'>. |
The RT System itself - Status changed from 'new' to 'open' |
From @schwern
Here it is again with that fixed plus the simple explaination lifted I also clarified in the cross-package example that the $bar used in C<our> associates a simple name with a package variable in the current If more than one value is listed, the list must be placed in our $foo; An C<our> declaration declares a global variable that will be visible package Foo; package Bar; |
From @schwernour.patch--- pod/perlfunc.pod 2005/07/13 21:05:44 1.1
+++ pod/perlfunc.pod 2005/07/15 02:08:16
@@ -3242,15 +3242,21 @@
=item our TYPE EXPR : ATTRS
-An C<our> declares the listed variables to be valid globals within
-the enclosing block, file, or C<eval>. That is, it has the same
-scoping rules as a "my" declaration, but does not create a local
-variable. If more than one value is listed, the list must be placed
-in parentheses. The C<our> declaration has no semantic effect unless
-"use strict vars" is in effect, in which case it lets you use the
-declared global variable without qualifying it with a package name.
-(But only within the lexical scope of the C<our> declaration. In this
-it differs from "use vars", which is package scoped.)
+C<our> associates a simple name with a package variable in the current
+package for the remander of the lexical scope. The listed variables
+are declared to be valid globals within the enclosing block, file, or
+C<eval>. That is, it has the same scoping rules as a "my"
+declaration, but does not create a local variable. When C<use strict
+'vars'> is in effect, the C<our> declaration lets you use the declared
+global variable without qualifying it with a package name. (But only
+within the lexical scope of the C<our> declaration. In this it
+differs from "use vars", which is package scoped.)
+
+If more than one value is listed, the list must be placed in
+parentheses.
+
+ our $foo;
+ our($bar, $baz);
An C<our> declaration declares a global variable that will be visible
across its entire lexical scope, even across package boundaries. The
@@ -3263,10 +3269,10 @@
$bar = 20;
package Bar;
- print $bar; # prints 20
+ print $bar; # prints 20 as it refers to $Foo::bar
Multiple C<our> declarations in the same lexical scope are allowed
-if they are in different packages. If they happened to be in the same
+if they are in different packages. If they happen to be in the same
package, Perl will emit warnings if you have asked for them.
use warnings;
|
From @steve-m-hayMichael G Schwern via RT wrote:
Thanks. Applied as change 25148. Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email. |
From @steve-m-hayNow fixed in bleadperl. |
@steve-m-hay - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#36538 (status was 'resolved')
Searchable as RT36538$
The text was updated successfully, but these errors were encountered: