In a message dated Thu, 3 Jan 2008, [EMAIL PROTECTED] writes:
+But these bindings I<do> autovivify:

    my %hash;
    my $val := %hash<foo><bar>;

    my @array;
-    my $obj = [EMAIL PROTECTED]; # $obj is a Capture object - see S02
+    my $cap = [EMAIL PROTECTED]; # $obj is a Capture object - see S02
+    my :($obj) := $cap;   # @array[0][0] created here

I'm wondering about that last line there.  Going by S02, I see:

   * There is now a generalized adverbial form of Pair notation. The
   following table shows the correspondence to the "fatarrow" notation:

   Fat arrow           Adverbial pair  Paren form
   =========           ==============  ==========
   [...]
   '' => $x            :($x)

which looks like C<:($obj)>.  So I was reading the line

   my :($obj) := $cap;   # @array[0][0] created here

as saying, "create an anonymous Pair, with $obj bound to its value, and bind the Pair to $cap (causing $obj to be bound to the value portion of $cap)".

But I was told on #perl6 that :($obj) refers to a Signature. If so, I think the relevant passage in S02 for deciphering the syntax is:

  A signature object (Signature) may be created with colon-prefixed
  parens:
      my ::MySig ::= :(Int, Num, Complex, Status :mice)

So in that case, $obj refers to... what? The variable's just been created, so its value is undef, so it's equivalent to a one-arg Signature with an undef item, and it's being used as an lvalue, so.... I don't understand.

Also, someone on #perl6 said that the colon could be omitted with no change in effect. I don't get that, either.

Given its use in the autovivification discussion in S09, the Pair idea made sense to me, but the Signature explanation is very confusing. I'd appreciate some help understanding it.

Trey

Reply via email to