Benjamin Golberg writes: > Luke Palmer wrote: > > > > > David Storrs wrote: > > > > > > > > Thinking about it, I'd rather see lvalue slices become a nicer version > > > > of C<splice()>. > > > > > > > > my @start = (0..5); > > > > my @a = @start; > > > > > > > > @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 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 >>; > > > > (those << >> brackets are new shorthand for qw, not that qw is going > > anywhere) > > Hmm... so, if I were to do: > > @x = map int(rand(6)), 1..3; > @[EMAIL PROTECTED] = "a" .. "e"; > print @a.length; > > Then, if the three integers in @x are consecutive, @a grows, but > otherwise it doesn't?
You know what would be nice? If I actually read what we were talking about (which can be seen at the top of this message %-). In general, (partially) because of this, I don't think slice splicing is a good idea; that's what the C<splice> function is for. The idea of lexical expansion is good, and slice splicing kills that. For example: @a[1..3] = << a b c d e >> Can be expanded in people's heads to: (@a[1], @a[2], @a[3]) = << a b c d e >> And I don't think that's something we want to get rid of. Luke > -- > $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;}