9

Add one to a junction of Ints:

put any( 1, 3, 7 ) + 1;

Now you have a junction of those Ints increased by one:

any(2, 4, 8)

So, 2 == any(2, 4, 8) is true.

Make a junction of strings and append to those strings:

put any( <h H> ) ~ 'amadryas';

You get a different result that doesn't equal 'hamadryas' or 'Hamadryas':

any("h", "H")amadryas

I expected something like:

any( 'hamadryas', 'Hamadryas' );

What's the difference in these operations that gives them different behavior even though they should be similar?

Pat
  • 36,282
  • 18
  • 72
  • 87
brian d foy
  • 129,424
  • 31
  • 207
  • 592

2 Answers2

1

on the High Sierra 10.13, put fails with:

put any( 1, 3, 7 ) + 1

This type cannot unbox to a native string: P6opaque, Junction in block at line 1

perl6 -v

This is Rakudo Star version 2017.10 built on MoarVM version 2017.10 implementing Perl 6.c.

chenyf
  • 5,048
  • 1
  • 12
  • 35
0

Quoting the filed bug report, as progressed by Zoffix++:

Thank you for the report. lizmat++ fixed this.

The put routine does not explicitly handle Junction arguments. As per design, the end result is therefore a call to put for each of its elements:

put any( 1, 3, 7 ) + 1;        # 2␤4␤8
put any( <h H> ) ~ 'amadryas'; # hamadryas␤Hamadryas

Per design, the call order of the puts is indeterminate. So other runs of the same code, perhaps with later compilers, may result in:

put any( 1, 3, 7 ) + 1;        # 4␤8␤2
put any( <h H> ) ~ 'amadryas'; # Hamadryas␤hamadryas

In contrast to put, the say routine does special case Junctions. So the end result is just a single call to say:

say any( 1, 3, 7 ) + 1;        # any(2, 4, 8)
say any( <h H> ) ~ 'amadryas'; # any(hamadryas, Hamadryas)
raiph
  • 31,607
  • 3
  • 62
  • 111