Good to see this investigated down to the details, yet I just realized
something that was bothering me about it. Going back to the original post:
submethod TWEAK {
$!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
) });
}
It's not good practice to use "map" for side effects only, discarding the
returned value–which happens here, and I think it is a cause of the
unexpected behavior.
Would this also work-around the lack of sink context in TWEAK?
submethod TWEAK {
for $!filelist.lines».split(',') -> ($a, $b) { @!show.push: ( $a, $b
) };
}
-y
On Sun, Mar 21, 2021 at 7:11 PM Ralph Mellor <[email protected]>
wrote:
> On Sun, Mar 21, 2021 at 9:47 PM <[email protected]> wrote:
> >
> > Waw! :) Following your examples and suggestions, these work:
> >
> > > class { submethod TWEAK(-->Nil) { Any.map: {say 99} } }.new;
> > > class { submethod TWEAK { sink Any.map: {say 99} } }.new;
> > > class { submethod TWEAK { eager Any.map: {say 99} } }.new;
> >
> > I really appreciate your discussion. Let me know if you think it
> > is worth to include this issue in the TWEAK Raku documentation.
>
> I think the first step is to see if it's considered a Raku(do) bug.
>
> I've filed an issue: https://github.com/rakudo/rakudo/issues/4260
>
> --
> love, raiph
>