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, c...@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?

Reply via email to