On Mon, May 25, 2020 at 8:54 AM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Sun, May 24, 2020 at 06:31:46PM -0400, David Mertz wrote:
>
> > I think one thing that pulls in different directions is that both
> > composition and piping are useful, and do something closely related.  But
> > in one the data "goes" forward and in the other the data "goes backward."
>
> The same rule applies to function application though.
>
> > I use bash a lot, and writing something like this is common:
> >
> > cat data | sort | cut -d; -f6 | grep ^foo | sort -r | uniq -c
>
> And today's "Useless Use Of cat Award" goes to... :-)
>
>     sort data | ...
>
> (What is it specifically about cat that is so attractive? I almost
> certainly would have done exactly what you did, even knowing that sort
> will take a file argument.)

<data sort | ...

(When you use cat in a pipeline: https://http.cat/304 )

> Compared to the regular old function call syntax:
>
>     uniq(sort(grep(cut(sort(data)))))
>
> (ignoring extra arguments) where the data still moves right to left.
>
> On the third hand, even if your language doesn't have pipes, it may have
> methods:
>
>     data.sort().cut().grep().sort().uniq()
>
> which now moves left to right again.
>

Maybe it's function call syntax that is the weird one. It might be
familiar to us, but maybe it's the one that's actually causing the
weirdness. Suppose we wrote the function last:

(data)sort

Now it's basically become a pipeline. And yet this syntax looks so
utterly bizarre that none of us would accept it...

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/PP4UPFFHX55V7U2FJDCRFSCZQ2XTHJ2C/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to