Thank you very much for your replies.
Silly me… I didn’t know the
I have been wondering why my scintilla in the shell stopped highlighting the decorator from PY35.
Now I got it.
Please let me continue the discussion.
The reason of using @
x @f @g => g(f(x)) and regard @ as an operator for f and g (not as a binary operator here).
Then, a product of @f and @g corresponds to the composition of g and f, but in reverse order.
This is the feature of ‘pullback’ that is a fundamental idea in the mapping theory.
The ‘pullback’ is like a mathematically defined synonym of ‘substitution’.
Since @decorator is also a kind of substitution, using the same symbol @ was natural to me.
Pros and cons
Yes, the symbol is not crucial. maybe |>, $<, $@, $(…), and whatever. However, we must take care that many symbols can significantly reduce readability. (in this point of view, Ruby is failing, I think).
It is Interesting to customize the right-hand-side operator. It really works! But here I don’t want to limit the specific class. I want to extend this feature to the parser of the shell.
Well, I forgot to mention that this topic is intended only for REPL time, not coding time. One may dislike that the syntax of REPL and actual python code is inconsistent. I agree too, but I can also show a few reasonable reasons for accepting this.
- The main purpose of REPL is to try it fast and learn what will happen.
- We shouldn’t feel stressed about typing. A good REPL will make the user’s learning curve steep.
- The history that the interpreter parsed as the actual python code can be recorded and used in the coding time (copy and paste).
Thanks for the efforts of all Python core developers and contributors.