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

.skip semantics are inconsistent #6558

Closed
p6rt opened this issue Sep 29, 2017 · 3 comments
Closed

.skip semantics are inconsistent #6558

p6rt opened this issue Sep 29, 2017 · 3 comments
Labels
6.d Related to the next 6.d language release

Comments

@p6rt
Copy link

p6rt commented Sep 29, 2017

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

Searchable as RT132184$

@p6rt
Copy link
Author

p6rt commented Sep 29, 2017

From @zoffixznet

- Seq.skip mutates the invocant​:
  $ ./perl6 -e 'my $s := (1, 2, 3).Seq; $ = $s.skip; say $s'
  (2 3)

- List.skip does not​:
  $ ./perl6 -e 'my $s := (1, 2, 3); $ = $s.skip; say $s'
  (1 2 3)

And the real pain point is that a cached Seq is basically a list.
Currently, .skip on a Seq crashes. I tried to fix[^1] the crash, but
the fixed version has these inconsistent semantics that `Seq.skip`
will either modify the invocant or not, depending on whether the Seq
is cached.

  $ ./perl6 -e 'm​: my $s := (1, 2, 3).Seq; $s.cache; $ = $s.skip; say $s'
  (1 2 3)
  $ ./perl6 -e 'm​: my $s := (1, 2, 3).Seq; $ = $s.skip; say $s'
  (2 3)

I don't see .skip in 6.c tests, so I think we still have a chance to
improve it. The question's​: how? Any ideas?

[1] https://gist.github.com/zoffixznet/98ee33398ac7979c0adc4a4a88696b85

@p6rt
Copy link
Author

p6rt commented Dec 11, 2017

From @zoffixznet

On Fri, 29 Sep 2017 09​:07​:40 -0700, cpan@​zoffix.com wrote​:

- Seq.skip mutates the invocant​:

No longer. It now consumes the iterator, which aligns the behaviour with Any.skip.

Fixed by lizmat++ in rakudo/rakudo@854c10c27e
Tests​: Raku/roast@49956451de

@p6rt
Copy link
Author

p6rt commented Dec 11, 2017

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

@p6rt p6rt closed this as completed Dec 11, 2017
@p6rt p6rt added the 6.d Related to the next 6.d language release label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.d Related to the next 6.d language release
Projects
None yet
Development

No branches or pull requests

1 participant