eager, hyper and race

a real usable Perl6 is imminent. So this weekend, I decide to play it around (the last action is 10 years ago). After one day playing, I feel it has evolved greatly! it's already a much fantastic language than perl5 even than I image it. of . It's cleaner, more logical, more consistent and built-in some important feature which perl5 hasn't.

Implicit parallel is one of the features I eager to have. In perl6, you can use 3 key words to speed up list operate(in parallel way):

eager: force non-lazy list processing

hyper: requests (but does not require) parallel evaluation. In any case, it declares that you don't care about the evaluation order, only the result order. (means it would block when one thread is not ready I think)

race: forces parallel evaluation of any iterator, hyper, or junction, such that if any single thread dies or hangs its computation, it does not block any other thread from returning its results to the race list.

It looks fantastic! doesn't it?
Sadly, when I tried:
my @c = 1..10;
eager @c.map: {say $_};
hyper @c.map: {say $_};
race @c.map: {say $_};
it throws some errors
and seems not implemented yet. or maybe I made some mistakes? anyway, I want use it in 2016! ;)

1 Comment

In the GLR branch the following is what you want:

my @c = 1..10;
@c.map({say $_}).eager;
@c.map({say $_}).hyper;
@c.map({say $_}).race;

You can build and play with specific branches using rakudobrew:

rakudobrew build moar glr
rakudobrew switch moar-glr
perl6

Leave a comment

About xiaoyafeng

user-pic I blog about Perl.