in reply to Re^3: aliasing arrays using typeglob under strict
in thread aliasing arrays using typeglob under strict
One may say that this effect may be avoided by remembering to carefully localize all package variables in all called functions,
Unintended side effects are unintended side effects:
sub G { our @ydata = 'Gaaaahh!'; };; sub F{ my @a = @_; print qq{pre-G: (@ydata)}; G(); print qq{post-G: (@ydata)}; };; F(1..4);; pre-G: () post-G: (Gaaaahh!)
The problem has nothing to do with aliasing and everything to do with not localising!
Your previous quote is better stated as: "don't use code that uses globals for no good reason.".
Which is doubly true for code that fails to localise its use of globals.
a healthy dose of paranoia.
Sorry, but I will always consider 'paranoia' in programming -- and pretty much everything else for that matter -- with exclusively negative connotations.
The teaching of 'paranoia', rather than 'knowledge', in an attempt to avert disaster, is always a counter productive and ultimately futile process.
With paranoia, one can only hope to avert bad consequences; with knowledge one can know you have.
Don't hope, know!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: aliasing arrays using typeglob under strict
by AnomalousMonk (Archbishop) on Feb 08, 2013 at 17:53 UTC | |
by BrowserUk (Patriarch) on Feb 08, 2013 at 18:10 UTC |