On Sun, May 24, 2020 at 11:17 PM Tim Peters <tim.peters@gmail.com> wrote:
[Guido]
>> I’ve never been able to remember whether (f@g)(x) means f(g(x)) or g(f(x)). That pretty much kills the idea for me.

[David Mertz]
> Well, it means whichever one the designers decide it should mean. But obviously it's a thing to remember,
> and one that could sensibly go the other way.
>
> On the other hand, when I showed an example using filter() a couple days ago, I had to try it to remember whether
> the predicate or the iterable came first. Lots of such decisions are pretty arbitrary.

Best I know, f@g applies g first in every language that implements a
composition operator, and in mathematics. While that may be arbitrary,
it's easy to remember:  (f@g)(x)  "looks a heck of a lot more like"
f(g(x)) than g(f(x)) because the former leaves the identifiers in the
same order.

I personally find it easy to remember, but I can imagine (perhaps incorrectly) how others may find it difficult. There's a 'wrong' rule that's equally easy to remember: f@g means call f then call g. In fact, when you think of it like that, you might not even notice that this means g(f(x)). So even if you know that f@g means f(g(x)), you can still mess this up by not thinking it through.

This is similar to when you have a list of decorators. Lots of people expect them to be called top to bottom (https://stackoverflow.com/questions/27342149/decorator-execution-order) and it's not easy to make the real order feel more intuitive.