I had assumed Perl6 will have copy-on-write references, so that

    $x = [1,2,3];
    @y = *$x;

would not require a copy. However, on thinking about it further, I
realized that that would get you in trouble here:

    $x = [1,2,3];
    %h{$x} = 1;
    @y = *x;
    $x[0]++;
    print %h{$x};

This would yield undef, as $x is now a newly created reference is it
not? Or would there be another level of indirection? Or will references
have some extra baggage which uniquely names them?

Of course, that all assumes that

    $x = [1 .. Inf];
    @y = *$x;

Is smart enough to not try to expand $x in the first place. Is this
going to be the case?





Reply via email to