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

.push does something un(ex)-spec'd-ed #4588

Closed
p6rt opened this issue Sep 25, 2015 · 7 comments
Closed

.push does something un(ex)-spec'd-ed #4588

p6rt opened this issue Sep 25, 2015 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Sep 25, 2015

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

Searchable as RT126172$

@p6rt
Copy link
Author

p6rt commented Sep 25, 2015

From songwentai@linuxdeepin.com

```perl6 code

my @​a = 1,2,3;
my @​b;
@​b.push​: @​a,;

```

@​b is [1,2,3], not [ [1,2,3] ], is this a bug?
in S07​:
http://design.perl6.org/S07.html
  @​a.push​: @​b,; # pushes 1 value (whatever is in @​b)
This is perl6 version 2015.09-115-g4653d98 built on MoarVM version 2015.09-36-g51dcbe4

@p6rt
Copy link
Author

p6rt commented Sep 25, 2015

From @lizmat

On 25 Sep 2015, at 06​:43, å®�æ��æ³° (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by ��泰
# Please include the string​: [perl #​126172]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126172 >

```perl6 code

my @​a = 1,2,3;
my @​b;
@​b.push​: @​a,;

```

@​b is [1,2,3], not [ [1,2,3] ], is this a bug?
in S07​:
http://design.perl6.org/S07.html
@​a.push​: @​b,; # pushes 1 value (whatever is in @​b)
This is perl6 version 2015.09-115-g4653d98 built on MoarVM version 2015.09-36-g51dcbe4

Thank you for letting us know.

The bug turns out to be in the spec​:

  http://irclog.perlgeek.de/perl6/2015-09-25#i_11273634

So the spec will be adapted.

Liz

@p6rt
Copy link
Author

p6rt commented Sep 25, 2015

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

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @FROGGS

The semantics of push got revised in the meantime, and a new method called "append" got added​:

m​: my @​a = 1,2,3; my @​b; @​b.push​: @​a,; dd @​b
rakudo-moar fae01f​: OUTPUT«Array @​b = [[1, 2, 3],]â�¤Â»

m​: my @​a = 1,2,3; my @​b; @​b.push​: @​a; dd @​b
rakudo-moar fae01f​: OUTPUT«Array @​b = [[1, 2, 3],]â�¤Â»

m​: my @​a = 1,2,3; my @​b; @​b.append​: @​a,; dd @​b
rakudo-moar fae01f​: OUTPUT«Array @​b = [1, 2, 3]â�¤Â»

m​: my @​a = 1,2,3; my @​b; @​b.append​: @​a; dd @​b
rakudo-moar fae01f​: OUTPUT«Array @​b = [1, 2, 3]â�¤Â»

As you can see even the comma is not needed anymore.
"push" will always push a single thing even if it is an array.
And "append" kinda flattens an input array or list, and will potentially append several items.

Tagging testneeded.

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @FROGGS

Added test​: Raku/roast@f50149e607

Closing ticket.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @FROGGS

Added test​: Raku/roast@f50149e607

Closing ticket.

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

@FROGGS - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant