Just when you thougth it was safe to go back on the mailing list,
Damian attempts to resurrect a dead can of worms:

And all because Mike Lazzaro wrote:

> Honestly, I still don't see what's so evil about R2L as:
>
>    @out = sort given map {...} given grep {...} given @a;

A few things.

First, C<given> already has a non-void-context meaning.

Second, I find this *really* hard to decipher. ;-)


Can I suggest that an alternative solution might be the following:

    Suppose Perl 6 had two new very low precedence operators: ~> and <~
    (a.k.a. "bind rightwards" and "bind leftwards")

    Suppose ~> takes its left argument and binds it to
    the end of the argument list of its right argument,
    then evaluates that right argument and returns the result.
    So an L2R array-processing chain is:

        @out = @a ~> grep {...} ~> map {...} ~> sort;

    There might also be a be special rule that, if the RHS is
    a variable, the LHS is simply assigned to it. Allowing:

        @a ~> grep {...} ~> map {...} ~> sort ~> @a;

    Further suppose that <~ takes its right argument, and binds
    it in the indirect object slot of the left argument, which
    argument it then calls. So an R2L array-processing chain is:

        @out = sort <~ map {...} <~ grep {...} <~ @a;

    Or, under a special rule for variables on the LHS:

        @out <~ sort <~ map {...} <~ grep {...} <~ @a;

That way, everything is still a method call, the ultra-low precedence of
<~ and ~> eliminate the need for parens, and (best of all) the expressions
actually *look* like processing sequences.

Damian


Reply via email to