develooper Front page | perl.perl5.porters | Postings from July 2005

[perl #2915] Inconsistent warnings with "our"

Thread Next
From:
Michael G Schwern via RT
Date:
July 14, 2005 16:17
Subject:
[perl #2915] Inconsistent warnings with "our"
Message ID:
rt-3.0.11-2915-117391.7.4605110471235@perl.org
So, to sum up... I think we all agree these should all warn.

    my $x;  our $x;  # this currently does not
    our $x; my $x;
    my $x;  my $x;
    our $x; our $x;

and that this should not

    package Foo;
    our $x;

    package Bar;
    our $x;

but this appears to be up in the air:

    package Foo;
    my $x;

    package Bar;
    our $x;

Currently this warns.  Rick's patch to fix "my $x; our $x;" changes this
so that it does not warn on the grounds that the "package Foo; our $x;
package Bar; our $x" case doens't warn either.  But I say that's a
special case to do with the fact that our's mix of two scoping
mechanisms, lexical and package, runs afoul of multi-package-in-one-file
programming idioms.

    package Foo;
    our @ISA = qw(...);  # or $VERSION or @EXPORT or ...

    package Bar;
    our @ISA = qw(...);

There's no corresponding idiom for "package Foo; my $x; package Bar; our
$x" or vice-versa.  Therefore, it should warn about the mask.


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