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

Junctions don't junct when routine has a slurpy, leading to inconsistent behaviour with core routines #6431

Closed
p6rt opened this issue Aug 7, 2017 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 7, 2017

Migrated from rt.perl.org#131856 (status was 'rejected')

Searchable as RT131856$

@p6rt
Copy link
Author

p6rt commented Aug 7, 2017

From @zoffixznet

Originally taken from​: https://stackoverflow.com/questions/45527881/why-does-and-affect-perl-6-junctions-differently

For example, there's a difference between output of using `+` and using `` with a Junction. With `+` you get a junction back, while `` slurps and just .Strs (which .perls) the Junction​:

  <Zoffix__> put any( 1, 3, 7 ) + 1;
  <Zoffix__> m​: put any( 1, 3, 7 ) + 1;
  <camelia> rakudo-moar a91ad2​: OUTPUT​: «any(2, 4, 8)␤»
  <Zoffix__> m​: put any( <h H> ) ~ 'amadryas';
  <camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")amadryas␤»

The reason is the `~` has a slurpy candidate, while `+` doesn't​:

Junction as just an arg​:
  <Zoffix__> m​: sub foo (+@​a) { @​a.join​: '|' }; say foo <h H>.any, 'amadryas'
  <camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")|amadryas␤»
  <Zoffix__> m​: sub foo (*@​a) { @​a.join​: '|' }; say foo <h H>.any, 'amadryas'
  <camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")|amadryas␤»

Junctioned call​:
  <Zoffix__> m​: sub foo ($a, $b) { ($a, $b).join​: '|' }; say foo <h H>.any, 'amadryas'
  <camelia> rakudo-moar a91ad2​: OUTPUT​: «any(h|amadryas, H|amadryas)␤»

There are two question​:
  1) Is it possible to make slurpies junct, same as non-Mu scalar candidates?
  2) If not, what do we do to make interface consistent; so that all the ops do the same thing?

@p6rt
Copy link
Author

p6rt commented Nov 29, 2017

From @AlexDaniel

This ticket needs an update because ~ was changed to DWIM with junctions, so all the examples in the ticket show something different (but the issue seems to be there).

I didn't go too deep into the details, but maybe these examples will do?

<AlexDaniel> m​: sub foo ($a, $b) { ($a, $b).max }; say foo <h H>.any, ‘amadryas’
<camelia> rakudo-moar 4a32089fd​: OUTPUT​: «any(h, amadryas)␤»
<AlexDaniel> m​: sub foo (*@​a) { @​a.max }; say foo <h H>.any, ‘amadryas’
<camelia> rakudo-moar 4a32089fd​: OUTPUT​: «amadryas␤»

On 2017-08-07 15​:34​:26, cpan@​zoffix.com wrote​:

Originally taken from​:
https://stackoverflow.com/questions/45527881/why-does-and-affect-perl-
6-junctions-differently

For example, there's a difference between output of using `+` and
using `` with a Junction. With `+` you get a junction back, while ``
slurps and just .Strs (which .perls) the Junction​:

<Zoffix__> put any( 1, 3, 7 ) + 1;
<Zoffix__> m​: put any( 1, 3, 7 ) + 1;
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any(2, 4, 8)␤»
<Zoffix__> m​: put any( <h H> ) ~ 'amadryas';
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")amadryas␤»

The reason is the `~` has a slurpy candidate, while `+` doesn't​:

Junction as just an arg​:
<Zoffix__> m​: sub foo (+@​a) { @​a.join​: '|' }; say foo <h H>.any,
'amadryas'
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")|amadryas␤»
<Zoffix__> m​: sub foo (*@​a) { @​a.join​: '|' }; say foo <h H>.any,
'amadryas'
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")|amadryas␤»

Junctioned call​:
<Zoffix__> m​: sub foo ($a, $b) { ($a, $b).join​: '|' }; say foo <h
H>.any, 'amadryas'
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any(h|amadryas,
H|amadryas)␤»

There are two question​:
1) Is it possible to make slurpies junct, same as non-Mu scalar
candidates?
2) If not, what do we do to make interface consistent; so that all
the ops do the same thing?

@p6rt
Copy link
Author

p6rt commented Nov 29, 2017

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

@p6rt
Copy link
Author

p6rt commented Dec 12, 2017

From @zoffixznet

On Mon, 07 Aug 2017 15​:34​:26 -0700, cpan@​zoffix.com wrote​:

Originally taken from​:
https://stackoverflow.com/questions/45527881/why-does-and-affect-perl-
6-junctions-differently

For example, there's a difference between output of using `+` and
using `` with a Junction. With `+` you get a junction back, while ``
slurps and just .Strs (which .perls) the Junction​:

<Zoffix__> put any( 1, 3, 7 ) + 1;
<Zoffix__> m​: put any( 1, 3, 7 ) + 1;
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any(2, 4, 8)␤»
<Zoffix__> m​: put any( <h H> ) ~ 'amadryas';
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")amadryas␤»

The reason is the `~` has a slurpy candidate, while `+` doesn't​:

Junction as just an arg​:
<Zoffix__> m​: sub foo (+@​a) { @​a.join​: '|' }; say foo <h H>.any,
'amadryas'
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")|amadryas␤»
<Zoffix__> m​: sub foo (*@​a) { @​a.join​: '|' }; say foo <h H>.any,
'amadryas'
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any("h", "H")|amadryas␤»

Junctioned call​:
<Zoffix__> m​: sub foo ($a, $b) { ($a, $b).join​: '|' }; say foo <h
H>.any, 'amadryas'
<camelia> rakudo-moar a91ad2​: OUTPUT​: «any(h|amadryas,
H|amadryas)␤»

There are two question​:
1) Is it possible to make slurpies junct, same as non-Mu scalar
candidates?
2) If not, what do we do to make interface consistent; so that all
the ops do the same thing?

Hello, Past Zoffix. How do you imagine slurpies would junct even? Scanning all elements (including nested ones) for Junctions?

Rejecting this as I don't see anything sane coming out from it.

The `~` was made to behave the same as `+` now; though the overall goalpost was moved and there's now a problem with output routines​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132549#ticket-history

@p6rt
Copy link
Author

p6rt commented Dec 12, 2017

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

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

No branches or pull requests

1 participant