Re: Using lists "containing" arrays as lvalues

2005-08-27 Thread Ingo Blechschmidt
Hi, Yuval Kogman wrote: > On Sat, Aug 27, 2005 at 19:16:55 +0200, Ingo Blechschmidt wrote: > >>my ($head, [EMAIL PROTECTED]) := foo(); > > if foo returns a list of scalars >=2 this is like parameter > unpacking: > > my ($head, [EMAIL PROTECTED]) = *foo(); [...] Right, but I wanted to d

Re: Binding of array elements

2005-08-27 Thread Ingo Blechschmidt
Hi, Yuval Kogman wrote: > On Sat, Aug 27, 2005 at 14:29:29 +0200, Ingo Blechschmidt wrote: >> * @foo[$idx] := $var; >> my @bar = @foo; >> $var= $new_var; >> # @foo[$idx] and $var are now $new_var, but @bar is unchanged, >> # right? > > Yes, I agree. But we do need a way in the

Re: Does list construction create new containers?

2005-08-27 Thread Ingo Blechschmidt
Hi, Yuval Kogman wrote: > On Sat, Aug 27, 2005 at 17:38:26 +0200, Ingo Blechschmidt wrote: >> ($foo, $bar)[0] =:= $foo; >> # False (i.e. no difference to arrays) or true? > > I think this is true, because you can say: > > ($foo, $bar) = (1, 2); > > And more curiously: > > for ($foo, $bar)

Re: Binding of array elements

2005-08-27 Thread Yuval Kogman
On Thu, Aug 25, 2005 at 23:29:03 +0200, Ingo Blechschmidt wrote: > * What happens if @array gets spliced? ... > @array.delete($some_index); @array[$some_index] = $some_value; > # or > @array[$some_index] = $some_value; the name 'splice' implies that things are removed, replaced, and t

Re: Binding of array elements

2005-08-27 Thread Yuval Kogman
On Sat, Aug 27, 2005 at 14:29:29 +0200, Ingo Blechschmidt wrote: > Ingo Blechschmidt wrote: > * @array[$out_of_bounds_index] := $var; > # Fatal error ("Can't rebind non-existant container")? > # Or autovivify @array[$out_of_bounds_index]? IMHO definately autovivify > > * @foo[$idx] := $var;

Re: Using lists "containing" arrays as lvalues

2005-08-27 Thread Yuval Kogman
On Sat, Aug 27, 2005 at 19:16:55 +0200, Ingo Blechschmidt wrote: >my ($head, [EMAIL PROTECTED]) := foo(); if foo returns a list of scalars >=2 this is like parameter unpacking: my ($head, [EMAIL PROTECTED]) = *foo(); if foo returns a scalar and an

Re: Does list construction create new containers?

2005-08-27 Thread Yuval Kogman
On Sat, Aug 27, 2005 at 17:38:26 +0200, Ingo Blechschmidt wrote: > Hi, > > * my @array = ; > @array[1] = "new"; > # Array elements are, of course, new (rw) containers. > > * my @array = ($foo, $bar); > > @array[0] =:= $foo; > # False -- array element are new containers. > > @array[0]

Using lists "containing" arrays as lvalues

2005-08-27 Thread Ingo Blechschmidt
Hi, (sorry for me going into implementation details, but, as it's really a language design question, I refrained from sending this to p6c.) While trying to make the following work in PIL2JS... my ($head, @tail) = foo(); it occured to me that this is bogus, or at least hard to implement. Wi

Re: Does list construction create new containers?

2005-08-27 Thread Juerd
Ingo Blechschmidt skribis 2005-08-27 17:38 (+0200): > I think these semantics are pretty clear. But what about lists? Lists are a language thing, not a data type. List elements can be lvalues. > ($foo, $bar)[0] =:= $foo; > # False (i.e. no difference to arrays) or true? I think this can be (

Does list construction create new containers?

2005-08-27 Thread Ingo Blechschmidt
Hi, * my @array = ; @array[1] = "new"; # Array elements are, of course, new (rw) containers. * my @array = ($foo, $bar); @array[0] =:= $foo; # False -- array element are new containers. @array[0] = $baz; # $foo unchanged I think these semantics are pretty clear. But what about lis

Re: Binding of array elements

2005-08-27 Thread Ingo Blechschmidt
Ingo Blechschmidt wrote: > Then we wondered what should happen to array elements which are bound > to other variables if some things happen to the array. (Of course, the > same thoughts apply to hashes as well). Two more questions: * @array[$out_of_bounds_index] := $var; # Fatal error ("Can't r