Hi all,

Apologies if this has been covered.  What should this do?

  ($x,$y) := ($y,$x);

In Perl5:

  $x=2; $y=3;
  print "x: $x y: $y\n";
  (*::x, *::y) = (*::y, *::x);
  $y=4;
  print "x: $x y: $y\n";
  $x=5;
  print "x: $x y: $y\n";

This program shows typeglob aliasing.  If we try to alias swapped
value, we merely swap what they are pointing at and we haven't aliased
anything.  I am not sure this should be appropriate behavior for Perl6.
 Aliasing will be much more common in Perl6 so this will be a trap for
many.  In fact, consider this:

  ($c, $d) := ($y, $x);
  # later
  ($x,$y) := ($c, $d); # whoops!

That's going to confuse the heck out of people.  If we do as Perl5
does, we'll merely be swapping values since aliasing really doesn't
make much sense here, but that means for this case, ":=" == "=".

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

Reply via email to