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

Reply via email to