Skip Menu |
Report information
Id: 83280
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: thundergnat <thundergnat [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Hyper += works incorrectly on an uninitialised array
Date: Wed, 2 Feb 2011 21:30:11 -0500
To: rakudobug [...] perl.org
From: thundergnat <thundergnat [...] gmail.com>
Download (untitled) / with headers
text/plain 911b
When using a hyper += to fill in values in an array, you get different behaviours depending on whether the array has been initialised or not. Some example code: my @h = (-8,-9); my @f = (-3,-6,-1); my @g = (24, 75, 62, 9); convolve(@f, @h); sub convolve (@f, @h) { my (@k, @l, @m); # set up three arrays @k = 0 xx + @f + @h - 1; # initialise @k to zeros @k[^@f X+ ^@h] >>+=<< (@f X* @h); # convolve into initialised array @l[^@f X+ ^@h] >>+=<< (@f X* @h); # convolve into uninitialised array. @m[^@f X+ ^@h] >>=<< (@f X* @h); # hyper = for comparison say ~@g; # correct answer (given) say ~@k; # correct answer (calculated) say ~@l; # wtf?? why is initialisation significant? say ~@m; # expected wrong (>>=<<) } Output: 24 75 62 9 24 75 62 9 24 48 8 9 24 48 8 9
Subject: Re: [perl #83280] [BUG] Hyper += works incorrectly on an uninitialised array
Date: Thu, 03 Feb 2011 11:29:53 +0100
To: perl6-compiler [...] perl.org
From: Moritz Lenz <moritz [...] faui2k3.org>
Download (untitled) / with headers
text/plain 433b
Am 03.02.2011 03:30, schrieb S. Schulze (via RT): Show quoted text
> When using a hyper += to fill in values in an array, you get different > behaviours depending on whether the array has been initialised or not.
Since hyper operators are generally sensitive to the shape of the data structures they work on, I don't think the mere fact that initialization matters is a bug. It might still be a bug in this specific case though. Cheers, Moritz
RT-Send-CC: moritz [...] faui2k3.org
Download (untitled) / with headers
text/plain 1.1k
On Thu Feb 03 02:30:10 2011, moritz wrote: Show quoted text
> > Am 03.02.2011 03:30, schrieb S. Schulze (via RT):
> > When using a hyper += to fill in values in an array, you get different > > behaviours depending on whether the array has been initialised or not.
> > Since hyper operators are generally sensitive to the shape of the data > structures they work on, I don't think the mere fact that initialization > matters is a bug. It might still be a bug in this specific case though. > > Cheers, > Moritz >
This is an old ticket, and I'm inclined to reject it… Hyper ops have a mixed order and are supposed be treated as though they were run in parallel, so running "»+=»" only makes sense when all of the arguments on the LHS are different containers. Assign-incrementing to each of @f[0, 1, 1, 2, 2, 3] in parallel is not likely to yield correct results, due to the replicated numbers. But, as Moritz said, this ticket may indicative of a bug that has to do more with initialization of Arrays than hyperops. This bug can be golfed to just: $ perl6 -e'my @f; @f[0,0].map({$_ += 1}); say @f' 1 $ perl6 -e'my @f = 0; @f[0,0].map({$_ += 1}); say @f' 2
Some discussion on what's going on here: https://irclog.perlgeek.de/perl6-dev/2017-03-06#i_14215098


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org