[Python-ideas] Function composition (was no subject)
Steven D'Aprano
steve at pearwood.info
Sun May 10 05:14:56 CEST 2015
On Sun, May 10, 2015 at 12:03:24AM +0200, Gregory Salvan wrote:
> Nobody convinced by arrow operator ?
>
> like: arg -> spam -> eggs -> cheese
> or cheese <- eggs <- spam <- arg
Absolutely not!
If we were designing a new language from scratch, I might consider arrow
operators. I think that they are cute.
But this proposal is going to be hard enough to get approval using
*existing* operators, | __or__ and @ __mat_mul__ (if I remember the
dunder methods correctly).
To convince people that we should support function composition as a
built-in feature, using NEW operators that will need the parser changed
to recognise, and new dunder methods, well, that will be virtually
impossible. numpy is one of the biggest and most important user bases
for Python, and it took them something like ten years and multiple
failed attempts to get enough support for adding the @ operator.
You *might* just have a chance for a -> right arrow operator, just
barely, but the left arrow <- operator is, I'm pretty sure, doomed to
failure. The problem is that the parser would need to distinguish these
two cases:
f<-x # f left-arrow x
f<-x # f less than minus x
and I don't think that is possible with Python's parser.
--
Steve
More information about the Python-ideas
mailing list