
On Sun, 26 Dec 2021 at 14:19, Steven D'Aprano <steve@pearwood.info> wrote:
Using a hypothetical pipeline syntax with an even more hypothetical arrow-lambda syntax:
[1, 2, 3] | map(x=>x+1) | filter(a=>a%2) | list
What is the pipeline syntax like indeed? It looks as if your ``|`` is an operator which produces callable objects, e.g., [1, 2, 3] | map such that calling it like [1, 2, 3] | map(x=>x+1) will be equivalent to map(x=>x+1, [1, 2, 3]) except that <an object> | list is apparently supposed to be a list without being called. But you might have actually meant to call it like [1, 2, 3] | map(x=>x+1) | filter(a=>a%2) | list() to get the list. The character ``|`` is OK with [1, 2, 3] , but it's already given a meaning as an operator e.g., with {1, 2, 3} . Can the syntax separate the different uses? I suppose it may be a new operator that you want. I thought some people had already essentially proposed an operator version of functools.partial although [1, 2, 3] | map will not exactly be equivalent to partial(map, [1, 2, 3]) because it's not map([1, 2, 3], x=>x+1) that you want. You want the arguments to be in a different order, but that's the only difference. Best regards, Takuo Matsuoka