Hi, Larry Wall wrote: > On Sat, Jul 30, 2005 at 02:33:15PM +0200, Ingo Blechschmidt wrote: > : my @array = <a b c>; > : my $arrayref := @array; [...] > : $arrayref = 42; # !!! 42 is not a Ref of Array > : > : Should the last line be treated as > : $arrayref = (42,); > : which, as the LHS is in scalar context, would auto-referize to > : $arrayref = [42]; > : which would work? > : > : Or should that be an error? > : > : (FWIW, I favour option 2.) > > Why shouldn't it do option 3, which is to work like in Perl 5? > It should only be an error if $arrayref is declared with a type > inconsistent with 42. Assignment goes to the container, not the > current contents of that container.
hm, I thought binding would make $arrayref and @array point to the same container? I.e.: my $a = 42; my $b; # $a --> Container1 --> 42 # $b --> Container2 --> undef $b := $a; # $a --> Container1 --> 42 # $b --> Container1 --> 42 (note: Container*1*) $a = 23; # $a --> Container1 --> 23 # $b --> Container1 --> 23 # But plain assignment does, of course, not change containers: my $c; # $c --> Container3 --> undef $c = $a; # $c --> Container3 --> 23 $a = 19; # $a --> Container1 --> 19 # $b --> Container1 --> 19 # $c --> Container3 --> 23 I.e. assignment goes to the container, but doesn't change it, and binding changes the container. --Ingo -- Linux, the choice of a GNU | Elliptic paraboloids for sale. generation on a dual AMD | Athlon! |