Any time someone expects something other than the defined result, it
suggests a need to clarify the documentation. (Unless they just
haven't RTFM.)

On 7/23/16, jn...@jnthn.net via RT <perl6-bugs-follo...@perl.org> wrote:
> On Fri Jul 22 15:34:02 2016, gfldex wrote:
>> my @numbers =  <4 8 15 16 23 42>; my $range = 0..2; .say for
>> @numbers[$range];
>> # OUTPUT«16␤»
>> # expected:
>> # OUTPUT«4␤8␤15␤»
>>
> This is correct, and part of the "Scalar container implies item" rule.
> Changing it would break things like the second evaluation here:
>
>> my @x = 1..10; my @y := 1..3; @x[@y]
> (2 3 4)
>> @x[item @y]
> 4
>
> Noting that since a range can bind to @y in a signature, then Range being a
> special case would make an expression like @x[$(@arr-param)] unpredictable
> in its semantics.
>
>> # also binding to $range provides the expected result
>> my @numbers =  <4 8 15 16 23 42>; my $range := 0..2; .say for
>> @numbers[$range];
>> # OUTPUT«4␤8␤15␤»
>> y
>
> This is also expected, since with binding there is no Scalar container to
> enforce treatment as an item.
>
> So, all here is working as designed.
>
>

Reply via email to