[Python-ideas] Infix functions

Haoyi Li haoyi.sg at gmail.com
Sat Feb 22 06:18:24 CET 2014


I like infix functions, but am no fan of the backtick syntax. Of all the
things that backticks mean to people: quotes, finger-quotes, code-snippets,
interpolate, whatever, "make me infix" is not one of them. Hard to type on
a keyboard is almost a non-reason in comparison. I know Haskell does it,
but... not that many people have used Haskell.

Another idea would be to go the Scala path and turn *methods* into infix
operators, by letting you call *point_a.add(point_b)* as *point_a add
point_b* or *point_a @add point_b *or some other special sigil. This is
semantically different from using infix functions because your infix
operators now do not clutter up your namespace, since they would be
properties of the LHS object. Not sure if it's "Pythonic", whatever that
means, but it's a neat idea that has found a lot of success in the Scala
world and I think is superior to the various other mechanisms for
infix-functions/operator-overloading that I see in Python/Ruby/C#/F#/etc.


On Fri, Feb 21, 2014 at 8:57 PM, Stephen J. Turnbull <stephen at xemacs.org>wrote:

> Chris Rebert writes:
>
>  > I think people using suboptimal fonts and keyboard layouts should find
>  > better ones...
>
> Replacement is not yet an option for people with suboptimal eyes and
> fingers.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140221/c0b3e5df/attachment.html>


More information about the Python-ideas mailing list