Agreed!
-y
On Mon, Mar 22, 2021 at 6:45 PM Ralph Mellor
wrote:
> On Mon, Mar 22, 2021 at 2:12 PM yary wrote:
> >
> > It's not good practice to use "map" for side effects only, discarding
> > the returned value–which happens here
>
> I agree.
>
> > Would [using `for`] also work-around the lack
On Mon, Mar 22, 2021 at 2:12 PM yary wrote:
>
> It's not good practice to use "map" for side effects only, discarding
> the returned value–which happens here
I agree.
> Would [using `for`] also work-around the lack of sink context in TWEAK?
Yes.
> I think it is a cause of the unexpected behavi
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 ef
On Sun, Mar 21, 2021 at 9:47 PM 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;
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
On Sun, Mar 14, 2021 at 2:12 AM Brad Gilbert wrote:
>
> Ralph, the last value in all functions are not sunk by default,
> so of course the last one in `TWEAK` is not sunk by default.
Right. Thanks for correcting this misleading part of my explanation.
> The bug is that the calling code is not si
Ralph, the last value in all functions are not sunk by default, so of
course the last one in `TWEAK` is not sunk by default.
This is intended behaviour.
It is up to the code that calls a function to sink the result if that is
the desired behaviour.
sub foo {
'a b c'.words».uc.map: *.s
Here's a golf:
class { submethod TWEAK { Any.map: {say 99} } }.new; #
class { submethod TWEAK { Any.map: {say 99}; 42 } }.new; # 99
class { submethod TWEAK (--> 42) { Any.map: {say 99} } }.new; # 99
The last line in a `BUILD` or `TWEAK` submethod is not eagerly evaluated
I think that this is caused because it is returning a 「Sequence」 that is
not getting sunk.
This is because the last value from a function is never sunk in that
function.
You could also use 「eager」 「sink」 or follow it with 「Nil」 or some other
value (instead of 「return」)
eager $!filelist.lines»
At the first glance it looks like bug. Possibly a result of over-optimization.
Worth opening an issue at https://github.com/rakudo/rakudo/issues
Best regards,
Vadim Belman
> On Mar 13, 2021, at 3:29 PM, mimosin...@gmail.com wrote:
>
> Hi,
>
> When working with this week challenge for the Perl
10 matches
Mail list logo