Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Stopping a package from infesting my namespace

by anneli (Pilgrim)
on Oct 08, 2011 at 23:37 UTC ( #930398=note: print w/ replies, xml ) Need Help??


in reply to Re: Stopping a package from infesting my namespace
in thread Stopping a package from infesting my namespace

Not bad! Thanks for your suggestion! I gave that a go; unfortunately it looks like Parse::Lex depends on those syms being there, and I hacked at it for quite some time without convincing it that they should be elsewhere. (I'd probably have to study it for some time longer, but the long and short of it is that I'd be monkeypatching a lot more than just exportTo(), so I'll leave it.)

For now I'll just leave my module non-reentrant, until I work out another way, or maybe switch lexer generator.

Thanks again!

Anne


Comment on Re^2: Stopping a package from infesting my namespace
Re^3: Stopping a package from infesting my namespace
by armstd (Friar) on Oct 09, 2011 at 02:20 UTC

    I guess my question then is are the reused symbols/tokens really a problem, or is it just the warnings? Do the tokens need to be scoped tighter than global to avoid conflict?

    If it's just the warnings, you can turn them off a variety of ways, like using 'use warnings;' (lexically scoped to just your own code) instead of 'perl -w' (global). If you do modify exportTo(), you can also just remove the Carp call. That 'if ($^W)' is just checking to see if warnings are enabled.

    --Dave

      I think it could technically cause an issue because the tokens contain subs which close on the environment around them; if someone used two of the parsers in different contexts, the latter one's state might end up being used for the former, too!

      So far I've tried to 'solve' this just by encapsulating these objects well enough such that they're never exposed to the user, so I deal with these issues in the interface (though the module becomes non-reentrant).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-08-31 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls