SPUG: "Clobberation" in ($c,$d)=($d,$c)
Brian Ingerson
briani at activestate.com
Mon Oct 9 14:07:33 CDT 2000
Daniel Chetlin wrote:
>
> During the Q&A session at the Perligata meeting, someone mentioned that
> if you alias a variable and then use it on one side of a variable
> switch, you get "clobberation". I was thinking about that tonight and
> decided to take a look, but I couldn't reproduce it.
>
> If memory serves, the problem was with constructs like:
>
> *e = \$c;
> ($c, $d) = ($d, $e);
>
> But that seems to work fine, so I must be remembering wrong. Can someone
> refresh my memory?
What Damian wrote on the board was not exactly what was needed to
produce the problem, just the basic idea. Try this:
(*c1, *d1) = (\$c, \$d);
($c, $d) = (10, 20);
($c, $d) = ($d1, $c1);
print "$c, $d\n";
The result should be perfectly clear :)
Brian
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list