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

Unclear what a hole in a List is #6592

Closed
p6rt opened this issue Oct 10, 2017 · 3 comments
Closed

Unclear what a hole in a List is #6592

p6rt opened this issue Oct 10, 2017 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Oct 10, 2017

Migrated from rt.perl.org#132261 (status was 'resolved')

Searchable as RT132261$

@p6rt
Copy link
Author

p6rt commented Oct 10, 2017

From @zoffixznet

If you convert an Array with holes into a List, it makes sense for holes to be turned in Nils,
and if you individually AT-POS them, Nil is indeed what you get. However, if you .perl or .gist that List,
or assign it to another Array with some `is default`, the Nils turn up to be Mus​:

  m​: my @​a = <a b c>; @​a[1]​:delete; @​a[5] = 42; @​a.List.gist.put; @​a.List.perl.put; my @​b is default(42) = @​a.List; say @​b.perl
  rakudo-moar b8eda6​: OUTPUT​: «(a (Mu) c (Mu) (Mu) 42)␤("a", Mu, "c", Mu, Mu, 42)␤["a", Mu, "c", Mu, Mu, 42]␤»

Which is especially weird, if you assign some Mus into the Array​:

  m​: (my @​a)[1] = Mu; @​a.List.gist.say
  rakudo-moar b8eda6​: OUTPUT​: «((Mu) (Mu))␤»
  m​: (my @​a)[1] = Mu; @​a.List[0,1].say
  rakudo-moar b8eda6​: OUTPUT​: «(Nil (Mu))␤»

Looks like the logic that turns holes into Nils on AT-POS also needs to be added in the iterator.

@p6rt
Copy link
Author

p6rt commented Oct 10, 2017

From @zoffixznet

On Tue, 10 Oct 2017 05​:56​:34 -0700, cpan@​zoffix.com wrote​:

If you convert an Array with holes into a List, it makes sense for
holes to be turned in Nils,
and if you individually AT-POS them, Nil is indeed what you get.
However, if you .perl or .gist that List,
or assign it to another Array with some `is default`, the Nils turn up
to be Mus​:

m​: my @​a = <a b c>; @​a[1]​:delete; @​a[5] = 42; @​a.List.gist.put;
@​a.List.perl.put; my @​b is default(42) = @​a.List; say @​b.perl
rakudo-moar b8eda6​: OUTPUT​: «(a (Mu) c (Mu) (Mu) 42)␤("a", Mu, "c",
Mu, Mu, 42)␤["a", Mu, "c", Mu, Mu, 42]␤»

Which is especially weird, if you assign some Mus into the Array​:

m​: (my @​a)[1] = Mu; @​a.List.gist.say
rakudo-moar b8eda6​: OUTPUT​: «((Mu) (Mu))␤»
m​: (my @​a)[1] = Mu; @​a.List[0,1].say
rakudo-moar b8eda6​: OUTPUT​: «(Nil (Mu))␤»

Looks like the logic that turns holes into Nils on AT-POS also needs
to be added in the iterator.

Made Array.List shove Nils into holes.

Fix​: rakudo/rakudo@e135121914
Test​: Raku/roast@2257ab353f

@p6rt p6rt closed this as completed Oct 10, 2017
@p6rt
Copy link
Author

p6rt commented Oct 10, 2017

@zoffixznet - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant