In the L2R thread, I made a comment where I contrasted a for loop
with a junction. On reflection, I think we could go further.

If we defined

    my $prev = 0;
    sub mangle($value) { $value + $prev; $prev=$value }

and then used it as:

   my $x = any(1,2,3);
   $y = mangle($x);

then the semantics of junctions are defined to fork 3 threads, to
evaluate C<mangle> for each member of the junction in an
arbitrary order. So there are now many possible values for
$y. For example: any(2,5,6) if the order of evaluation is 2,3,1.

Let us now imagine that C<for> is a junction operator, instead of a
looping statement. Now we could write:

   my $x = for(1,2,3);
   my $y = mangle($x);

and we can be certain that $y == (1,3,6), because a "for-junction"
will distribute that evaluations sequentially.

This ties in nicely with the pipeline syntax discussion, because

   for 1,2,3 ~> print;
and
   for 1,2,3 -> { print };

would naturally behave correctly. But by defining a special type of
sequentially distributed junction, we can do all sorts of clever (and
therefore nasty) things.


Dave.

--
mailto:[EMAIL PROTECTED]; http://dave.whipp.name


Reply via email to