On Fri Aug 20 17:53:36 2010, pmichaud wrote:
> On Fri, Aug 20, 2010 at 03:42:57PM -0700, Carl Mäsak wrote:
> > <masak> rakudo: my %h = foo => []; for %h<foo> -> $a { say $a.perl }
> > <p6eval> rakudo 7b0031: OUTPUT«[]»
> > <masak> I find I do such hash accesses when iterating on quantified
> > Match objects. I'd like to know if I should write %h<foo> or
> > %h<foo>.list in the for statement.
> > <masak> not least because bitrot in my code seems to indicate that
> > the
> > behaviour changed in Rakudo recently :)
> > <TimToady> I think that one should flatten
>
> Initially I disagree. Consider:
>
> my %h = abc => [1,2,3], def => 4; for %h<abc def> -> $x { say
> $x.perl; }
>
> I'd expect that loop to iterate twice, not 4 times.
> In general, I think that .{ } and .[ ] on arrays and hashes
> tend to produce scalar containers (which don't flatten by default).
>
> To get an array in a hash element to flatten, I'd suggest @%h<abc> .
>
> TimToady can override this interpretation, in which case we'll
> switch Rakudo to match. But I fear making hash and array elements
> flattening by default will have far-reaching ramifications to other
> things we're doing.
>
> Pm
Sorry about the delay.
02:53 < [Coke]> Here's another ticket that requires a ruling, and perhaps a
rethink in the 3.5 years since it was opened: RT #77340
02:58 < TimToady> given current understanding of how things itemize, I think Pm
has it right, and we should reject the ticket
02:58 < TimToady> except that @%h<abc> can't work
02:58 < TimToady> must be either @(%h<abc>) or %h<abc>.list or %h<abc>[]
Rejecting ticket, sorry.
--
Will "Coke" Coleda