in reply to Re: Code brewing for the upcoming MCE 10 year anniversary
in thread Code brewing for the upcoming MCE 10 year anniversary

Update: Changed to "spawn" without the "_each" suffix. Thank you, choroba.

I updated the prior example. Seeing "spawneach" made me rename it to "spawn_each". I can leave out the "_each" suffix, but preferred to be clear that "spawn_each" will be spinning a child process per each element.

# serial code foreach my $i (30..38) { say "$$: $i"; } # this seems clear? spawn_each my $i (30..38) { say "$$: $i"; } # will this confuse folks? spawn my $i (30..38) { say "$$: $i"; }

Which one do you prefer (spawn_each, spawn) or something else? The "spawn" without the "_each" suffix is elegant, but wonder if folks will think not spawning a child process per element.

MCE::Simple is quite nice. It does not alter the line count when filtering / transposing to parallel code.

Replies are listed 'Best First'.
Re^3: Code brewing for the upcoming MCE 10 year anniversary
by 1nickt (Canon) on Nov 11, 2022 at 13:04 UTC

    Hi Mario

    Maybe spawn_for_each ... ?


    The way forward always starts with a minimal test.

      Yesterday, I had code supporting spawn foreach and for.

      spawn foreach my $i (30..38) { say "$$: $i"; } spawn for my $i (30..38) { say "$$: $i"; }