I was trying to implement unary * (list flatten or "splat" operator) in pugs yesterday, and I came to the conclusion that I really don't grok how context works in Perl6 (I also really don't grok Haskell, but this is another story...).


if I understand correctly, all these are equivalents:

  my @a = 1,2,3;
  my @a = (1,2,3);
  my @a = list 1,2,3;
  my @a = [1,2,3]; # or does it make @a[0] = (1,2,3)?

and all these are too (they make $a a reference to an array):

  my $a = 1,2,3;
  my $a = (1,2,3);
  my $a = list 1,2,3;
  my $a = [1,2,3];

I'm not sure what the following do (assign 1 to $a maybe?):

  my $a = [EMAIL PROTECTED];
  my $a = *(1,2,3); # or is this a syntax error?
  my $a = *(list 1,2,3);
  my $a = *[1,2,3];

and I have absolutely no clue about the following:

  my *$a = @a;
  my *$a = [EMAIL PROTECTED];
  my *$a = (1,2,3);
  my *$a = [1,2,3];

thanks for any help.

cheers,
Aldo



Reply via email to