One possibility for R-to-L pipelines that would also solve the
namespace issues associated with reserving lots of keywords like "map"
and "grep" and "part" would be to have a quite literal inverse-C<.>
grammar. So instead of saying
$a.foo(args)
you could _always_ say an equivalent
foo(args) <- $a;
Where the invocant $a is at the right, not the left.
(I know, I know... <- is just a PLACEHOLDER. Ambiguous, etc.)
This would allow our visual R-to-L pipelines:
@out = sort {...} <- map {...} <- grep {...} <- @in;
The primary advantage is that C<map>, etc. are *not* reserved keywords,
but simply object methods of @Array. You might even override C<grep>
for individual subclasses of Array, for example, perhaps to attach
additional variants.
The namespace issues are thus lessened considerably, as it takes the
"specialness" away from the particular C<map>-like keywords and puts it
in the grammar.
And parens might not be needed in the pipe, _if_ <- is parsed as
grammar (similar to how postconditions work), not as an op.
But parsing it may be tricky, in that you can't get the invocant until
you've already parsed the method name and args. So methods must either
always have parens, or always slurp up all possible args -- anything
else is still ambiguous.
MikeL
- Re: right-to-left pipelines Dan Sugalski
- Re: right-to-left pipelines Damian Conway
- RE: right-to-left pipelines Brent Dax
- Re: right-to-left pipelines Simon Cozens
- RE: right-to-left pipelines Brent Dax
- Re: right-to-left pipelines Uri Guttman
- RE: right-to-left pipelines Brent Dax
- Re: right-to-left pipelines Jonathan Scott Duff
- Re: right-to-left pipelines Adam D. Lopresto
- Re: right-to-left pipelines Jonathan Scott Duff
- Re: right-to-left pipelines Michael Lazzaro
- Re: right-to-left pipelines Smylers
- Re: right-to-left pipelines Andy Wardley
- Re: right-to-left pipelines Damian Conway
- Re: right-to-left pipelines Trey Harris
- Re: right-to-left pipelines Stéphane Payrard
- Re: right-to-left pipelines Dave Whipp
- Re: right-to-left pipelines Dave Storrs
- Re: right-to-left pipelines Damian Conway
- Re: purge: opposite of grep Ken Fox
- Re: purge: opposite of grep Damian Conway