Gordon Henriksen writes:
> Taking a thread from Perl 6 Internals. Will Perl 6 support this behavior?
> 
>       $ perl <<'EOT'
>               my @ary;
>               my $ref = \$ary[0];
>               $$ref = "value";
>               print '$ary[0] : ', $ary[0], "\n";
>       EOT
>       $ary[0] : value
>
> Presumably the Perl 6 would be:
> 
>       my @ary;
>       my $ref = [EMAIL PROTECTED];
>       $$ref = "value";
>       print '@ary[0] : ', @ary[0], "\n";   # -> @ary[0] : value

That has to do with autovivification semantics.  Particularly, do things
autovivify when you take a nonconstant reference to them.  I think they
should, and that wasn't one of those cases where autovivi was broken, so
it probably will.

> If that's supported, then how will this behave?
> 
>       my @cows of Cow;
>       my $slot = [EMAIL PROTECTED];
>       $$slot = new Dog;
> 
> Do we wind up with Clarus or an exception? (Never mind whether you take 
> exception with Clarus.) Hopefully an exception, from a user's POV. 

Definitely.

> And this?
> 
>       my @cows of Cow:
>       my @cats of Cat;
>       my $ref = [EMAIL PROTECTED];
>       @cats[0] := $$ref;
>       @cats[1] := @cows[0];   # Just to hammer the point home....
>       $$ref = new Dog;

I would assume that's also an error.  @cats C<returns Cat> [1], and if
you bind part of it to something that returns a non-cat, there should be
an exception... or a compile error.

Luke

> But then there's a question for p6i as to how all the above happens.
> 
> —
> 
> Gordon Henriksen
> [EMAIL PROTECTED]
> 

Reply via email to