At 01:31 PM 5/21/2001 +1000, Damian Conway wrote:
>    > Um, this is a tiny little diversion here prompted by something that
>    > came up on perl-beginners, of all places... it's not possible in
>    > perl 5 to make a reference to an array or hash slice without doing
>    > some copying.
>    >
>
>Hey, this is *Perl*! Of course it's possible...
>
>@A = (1..10);   # array
>@I = (3..5);    # indices of desired slice
>
>$ref =
>  sub{my%k;@k{@{+pop}}=\(@_);splice@_,$_,!$k{$_}for reverse 
> 0..@_;\@_}->(@A,\@I);

Oh, well, if I'd known it was *that* succinct...

But... that *does* involve copying; the original poster was talking about 
huge arrays where copying was actually significant.  You've got the list of 
keys and values in the temporary hash there.  It certainly violates the 
spirit of the request.  Which still seems like a reasonable request.

A reference to a slice in perl 5 yields the list of the references to the 
slice members.  Is that the way it's going to be in perl 6?

Reply via email to