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

.first with a junction unexpectedly returns a junction (<a b c>.first: ‘a’|‘c’) #5681

Closed
p6rt opened this issue Sep 18, 2016 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Sep 18, 2016

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

Searchable as RT129304$

@p6rt
Copy link
Author

p6rt commented Sep 18, 2016

From @AlexDaniel

Differences between 2015.12 and HEAD​:

<AlexDaniel> committable6​: 2015.12,HEAD <a b c d b e>.first(‘b’|‘a’).say
<committable6> AlexDaniel, ¦«2015.12»​: aâ�¤¦«HEAD»​: any(b, a)

<AlexDaniel> committable6​: 2015.12,HEAD <a b c d b e>.first(‘b’|‘a’, :end).say
<committable6> AlexDaniel, ¦«2015.12»​: bâ�¤¦«HEAD»​: any(b, a)

In other words, .first used to return the first element even if you pass a junction as a parameter. Now it returns another junction.

Bisectable points to this commit​: rakudo/rakudo@157b46e

<timotimo> we're really hoping to use a matcher there, i think
<masak> .grep uses a matcher, and so .first ought to also

IRC discussion originates here​: http://irclog.perlgeek.de/perl6/2016-09-18#i_13233528
But useful comments start here​: http://irclog.perlgeek.de/perl6/2016-09-18#i_13233576

@p6rt
Copy link
Author

p6rt commented Sep 18, 2016

From @BenGoldberg1

Here is a snippet from #perl6 on freenode​:

<BenGoldberg> m​: ('a', 42, 'b', 22/7, 'c', 23).first(Int|Rat, :kv).say
<+camelia> rakudo-moar 641ee1​: OUTPUT«any((1 42), (3 3.142857))â�¤Â»

The result I expected was OUTPUT«(1 42)�»

The docs say that the first argument for .first is Mu $matcher, and therefor autothreading should not happen.

Rakudo implements .first using a couple of internal helper methods, !first-accepts and !first-accepts-end, located here​: https://github.com/rakudo/rakudo/blob/641ee1e/src/core/Any-iterable-methods.pm#L1185 and
https://github.com/rakudo/rakudo/blob/641ee1e/src/core/Any-iterable-methods.pm#L1201

Both of these helpers have a first argument of $test, which is untyped, and is therefor of type Any.

Because of this, when either of these helper methods is called with a Junction, autothreading occurs.

So, if you could add a couple of Mu�s, I�d appreciate it.

Thanks, Ben Goldberg

@p6rt
Copy link
Author

p6rt commented Sep 19, 2016

From @lizmat

This is a dup of #​129304, which has been fixed with c78f5dc7df5b1398d2867 , tests needed.

On 19 Sep 2016, at 01​:00, Benjamin Goldberg (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Here is a snippet from #perl6 on freenode​:

<BenGoldberg> m​: ('a', 42, 'b', 22/7, 'c', 23).first(Int|Rat, :kv).say
<+camelia> rakudo-moar 641ee1​: OUTPUT«any((1 42), (3 3.142857))â�¤Â»

The result I expected was OUTPUT«(1 42)�»

The docs say that the first argument for .first is Mu $matcher, and therefor autothreading should not happen.

Rakudo implements .first using a couple of internal helper methods, !first-accepts and !first-accepts-end, located here​: https://github.com/rakudo/rakudo/blob/641ee1e/src/core/Any-iterable-methods.pm#L1185 and
https://github.com/rakudo/rakudo/blob/641ee1e/src/core/Any-iterable-methods.pm#L1201

Both of these helpers have a first argument of $test, which is untyped, and is therefor of type Any.

Because of this, when either of these helper methods is called with a Junction, autothreading occurs.

So, if you could add a couple of Mu�s, I�d appreciate it.

Thanks, Ben Goldberg

@p6rt
Copy link
Author

p6rt commented Sep 19, 2016

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

@p6rt
Copy link
Author

p6rt commented Sep 20, 2016

From @zoffixznet

Tests added in Raku/roast@7cdeab4a68

@p6rt
Copy link
Author

p6rt commented Sep 20, 2016

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

@p6rt p6rt closed this as completed Sep 20, 2016
@p6rt p6rt added the testneeded 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
Development

No branches or pull requests

1 participant