Dave Whipp wrote:
> "Luke Palmer" wrote:
> > Benjamin Goldberg wrote:
> > > David Storrs wrote:
> > > >      @a[1..3] = qw/ a b c d e /;
> > > >      print @a;   #  0 a b c d e 4 5
> > >
> > > What would happen if I used 1,2,3 instead of 1..3?
> > > Would it do the same  thing?
> >
> > Of course.
> 
> I tend to agree, I think. But see below
> 
> > > I wanna know what happens if I do:
> > >
> > >        @a[0,2,4] = qw/ a b c d e /;
> >
> > It would probably do the same as in Perl 5; the same thing as:
> >
> >     @a[0,2,4] = << a b c >>;
> 
> But that would be awful:
> 
>    @a[$x,$y] = <<a b c d e>>
> 
> would insert all 5 elements if ($y == $x+1); but only the first two
> otherwise. Belch.
> 
> If we wanted the array-splice thing to resize arrays for us, then either
> we trigger the behavior only when rx/ \[ <scalar> \.\. <scalar> \]/, or

AFAIK, in perl6, $a..$b doesn't create an expanded list... it creates a
lazy list, which gets expanded as-needed.  Most likely, this list
object, and the list object representing the values being stored there,
would be handed directly to the @a array object, just as if we'd done
code like:

   @a[ new LazyIntRange(1,3) ] = new LazyStrRange("a","e");

So, @a can say, "hey, this is a Range, not merely a list of 1,2,3... I
should instead splice() the values in"

> we need to define the spilling algorithm in a way that makes sense (e.g.
> all remaining items go into the element of the righmost index).
>
> But perhaps there's a better way to beet the desire. Perhaps ellipses
> could be emplyed to indicate that the splice is allowed to resize the
> array:
> 
>   @a[1...3] = qw(a b c d e);

That might work, too.

My way is more invisible, but then again, if someone *wants* to have
@a[1,2,3,4,5,6,7,8,9] = @x, and writes it as @a[1..9] = @x, and is
surprised by perl doing a splice, it would be bad; with "..." it would
only splice when the user asks for a splice.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "[EMAIL PROTECTED]
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Reply via email to