in reply to Re^6: use has it's own scope?
in thread use has it's own scope?

Yeah, I see the argument for making it a warning.

Detecting this case is complicated, though. Unlike pseudo-state variables, it's not a shaky part of syntax and composition and implementation. At best, you might be able to express that a lexical variable appears to be used only once, but I can still imagine a bizarre module interface which closes over the using scope's lexical.

Replies are listed 'Best First'.
Re^8: use has it's own scope?
by jdporter (Paladin) on Aug 08, 2017 at 18:42 UTC
    I can still imagine a bizarre module interface which closes over the using scope's lexical

    I can, too; but I tried, and I don't think it can be done -- at least not without resorting to something in the B namespace. You could probably do it, though. ;-)

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

      Doesn't keeping the elements in @_ basically have the same effect since they are aliases to the values in the use statement?

      package Set; sub import { our $var = \$_[1]; } 1;
      With this module, perl -e "use Set (my $x = 6,); $$Set::var++; will work but perl -e "use Set (6,); $$Set::var++;

      will fail because "Modification of a read-only value attempted at -e line 1."

        ( /me diabolic laughter ;-)

        yes, I will link to my YAPC talk as soon that I find it on youtube. :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

      > resorting to something in the B namespace.

      That's my plan ... ;)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!