Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array accesses to the same location autoviv seperately #2344

Open
p6rt opened this issue Feb 3, 2011 · 5 comments
Open

Array accesses to the same location autoviv seperately #2344

p6rt opened this issue Feb 3, 2011 · 5 comments
Labels
Bug

Comments

@p6rt
Copy link

@p6rt p6rt commented Feb 3, 2011

Migrated from rt.perl.org#83280 (status was 'open')

Searchable as RT83280$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Feb 3, 2011

From @thundergnat

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

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Feb 3, 2011

From @moritz

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

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Feb 3, 2011

The RT System itself - Status changed from 'new' to 'open'

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Mar 11, 2015

From @Mouq

On Thu Feb 03 02​:30​:10 2011, moritz wrote​:

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

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Mar 6, 2017

From @zoffixznet

Some discussion on what's going on here​: https://irclog.perlgeek.de/perl6-dev/2017-03-06#i_14215098

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.