Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^7: use has it's own scope?

by chromatic (Archbishop)
on Aug 08, 2017 at 16:48 UTC ( #1197013=note: print w/replies, xml ) Need Help??


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 (Canon) 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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1197013]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-08-18 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (185 votes). Check out past polls.

    Notices?