Re: Aliasing an array slice

2003-07-20 Thread David Storrs
On Fri, Jul 18, 2003 at 06:05:52PM -0400, Benjamin Goldberg wrote: What would happen if I used 1,2,3 instead of 1..3? Would it do the same thing? I would think so. I wanna know what happens if I do: @a[0,2,4] = qw/ a b c d e /; Yup, you're right, I didn't consider

Re: Aliasing an array slice

2003-07-18 Thread Benjamin Goldberg
David Storrs wrote: Thinking about it, I'd rather see lvalue slices become a nicer version of Csplice(). 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

Re: Aliasing an array slice

2003-07-18 Thread Luke Palmer
David Storrs wrote: Thinking about it, I'd rather see lvalue slices become a nicer version of Csplice(). 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?

Re: Aliasing an array slice

2003-07-18 Thread Benjamin Goldberg
Luke Palmer wrote: David Storrs wrote: Thinking about it, I'd rather see lvalue slices become a nicer version of Csplice(). 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

Re: Aliasing an array slice

2003-07-18 Thread Dave Whipp
Luke Palmer [EMAIL PROTECTED] 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

Re: Aliasing an array slice

2003-07-18 Thread Benjamin Goldberg
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.

Re: Aliasing an array slice

2003-07-18 Thread Luke Palmer
Benjamin Golberg writes: Luke Palmer wrote: David Storrs wrote: Thinking about it, I'd rather see lvalue slices become a nicer version of Csplice(). my @start = (0..5); my @a = @start; @a[1..3] = qw/ a b c d e /; print @a; # 0 a b c

Re: Aliasing an array slice

2003-07-09 Thread David Storrs
On Tue, Jul 08, 2003 at 05:52:04PM -0700, Austin Hastings wrote: --- Jonadab the Unsightly One [EMAIL PROTECTED] wrote: Am I now thinking clearly? I don't think so. If you've created two separate arrays that happen to start with related values, then the changes to the first won't

Re: Aliasing an array slice

2003-07-09 Thread Austin Hastings
--- David Storrs [EMAIL PROTECTED] wrote: On Tue, Jul 08, 2003 at 05:52:04PM -0700, Austin Hastings wrote: --- Jonadab the Unsightly One [EMAIL PROTECTED] wrote: Am I now thinking clearly? I don't think so. If you've created two separate arrays that happen to start with

Re: Aliasing an array slice

2003-07-08 Thread Jonadab the Unsightly One
David Storrs [EMAIL PROTECTED] writes: my $r_slice = [EMAIL PROTECTED]; @$r_slice = qw/ a b c d e /; print @a; # 0 a b c d e 4 5 This seems right to me. It would take approximately no time to get used to this semantic, IMO. # Note that it does NOT modify in rvalue

Re: Aliasing an array slice

2003-07-08 Thread Jonadab the Unsightly One
Jonadab the Unsightly One [EMAIL PROTECTED] writes: Does this imply, though, that it's pointing to specific elements, Wow, I wasn't paying attention to what I was thinking there. Obviously it points to specific elements, because the subscripts used to create a slice don't have to be sequential

Re: Aliasing an array slice

2003-07-08 Thread Austin Hastings
--- Jonadab the Unsightly One [EMAIL PROTECTED] wrote: Jonadab the Unsightly One [EMAIL PROTECTED] writes: Does this imply, though, that it's pointing to specific elements, Wow, I wasn't paying attention to what I was thinking there. Obviously it points to specific elements, because the

Re: Aliasing an array slice

2003-07-07 Thread David Storrs
Thinking about it, I'd rather see lvalue slices become a nicer version of Csplice(). 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 # Similarly: @a = @start; my $r_slice = [EMAIL PROTECTED]; @$r_slice =

Re: Aliasing an array slice

2003-07-06 Thread Dan Brook
On 5 Jul 2003, Luke Palmer wrote: return [EMAIL PROTECTED] $begin .. $end ]; I fear that this might take a reference to each element in the slice, rather than a reference to the slice Yes, that would indeed return a list of refs in perl5. Can it also be assumed that the magic

Re: Aliasing an array slice

2003-07-05 Thread dbrook
On Fri, 4 Jul 2003, Damian Conway wrote: Will it be possible (or sane even) to bind a variable to an array slice It *should* be, since it's possible (if ungainly) to do it in Perl 5: Ouch, blatant abuse of perl5's aliasing with @_ and globs ;) Can I also assume that you can also pass around a

Re: Aliasing an array slice

2003-07-05 Thread Luke Palmer
On Fri, 4 Jul 2003, Damian Conway wrote: Will it be possible (or sane even) to bind a variable to an array slice It *should* be, since it's possible (if ungainly) to do it in Perl 5: Ouch, blatant abuse of perl5's aliasing with @_ and globs ;) Can I also assume that you can also pass

Re: Aliasing an array slice

2003-07-05 Thread Nicholas Clark
On Sat, Jul 05, 2003 at 09:51:29AM -0600, Luke Palmer wrote: Actually, you can't reference a slice! Where the heck does the reference point? I would probably do: Of course not. I presume it points to something non-existent just like a substring reference would in perl5 :-) $ perl -le '$a =

Re: Aliasing an array slice

2003-07-05 Thread Luke Palmer
On Sat, Jul 05, 2003 at 09:51:29AM -0600, Luke Palmer wrote: Actually, you can't reference a slice! Where the heck does the reference point? I would probably do: Of course not. I presume it points to something non-existent just like a substring reference would in perl5 :-) $ perl

Re: Aliasing an array slice

2003-07-05 Thread Luke Palmer
On Sat, Jul 05, 2003 at 09:51:29AM -0600, Luke Palmer wrote: Actually, you can't reference a slice! Where the heck does the reference point? I would probably do: Of course not. I presume it points to something non-existent just like a substring reference would in perl5 :-)

Aliasing an array slice

2003-07-04 Thread Dan Brook
Will it be possible (or sane even) to bind a variable to an array slice e.g ## correct syntax? my @array = a list of values ; my @array_slice := @array[ 1 .. @array.end ]; Or would this merely bind @array_slice to the list returned by the slice, or would it DTRT (in my eyes at least) and

Re: Aliasing an array slice

2003-07-04 Thread Luke Palmer
Will it be possible (or sane even) to bind a variable to an array slice e.g ## correct syntax? my @array = a list of values ; my @array_slice := @array[ 1 .. @array.end ]; Yeah, that'll work. It has to, lest: my [EMAIL PROTECTED] := (1, 1, map { $^a + $^b } zip(@fibs,

Re: Aliasing an array slice

2003-07-04 Thread Damian Conway
Dan Brook wrote: Will it be possible (or sane even) to bind a variable to an array slice It *should* be, since it's possible (if ungainly) to do it in Perl 5: use Data::Dumper 'Dumper'; @bar = (1,2,3); *foo = (sub [EMAIL PROTECTED])-(@bar[1,0,3]); print Dumper [EMAIL PROTECTED];