[Python-ideas] Infix functions

Bruce Leban bruce at leapyear.org
Sun Feb 23 08:17:54 CET 2014


On Sat, Feb 22, 2014 at 9:30 PM, Andrew Barnert <abarnert at yahoo.com> wrote:

> On Feb 22, 2014, at 19:17, Bruce Leban <bruce at leapyear.org> wrote:
>
> However, there is still a big problem typing these symbols. Unicode hasn't
> meant a resurgence in APL, after all... A handful of them are available as
> opt-sequences on Mac, but most aren't. And on other platforms, where you
> have to use alt+keypad, none of them are typeable. Of course powerful
> enough editors can easily take care of this problem, but is it acceptable
> to say "if you want to use fancy operators, you have to use emacs, vi, or
> some not-yet-released version of Eclipse or PyCharm"? (Maybe it is; this is
> a real question, not rhetorical...) And it's not just editing code; if I
> want to import a module at the interactive prompt in my terminal or
> IDLE and call one of these functions, if I want to write a code snippet in
> an email or a StackOverflow answer, etc., I need an input method that works
> there (or I need to copy and paste from emacs).
>

These are legitimate questions. I would hate to see substitute n-graphs
like in C: https://en.wikipedia.org/wiki/Digraphs_and_trigraphs. And having
this feature and then having everyone write A <<intersect>> B instead
doesn't have much of an advantage.

On the other hand, I haven't seen any replies from people saying they can't
read these characters. So the real issue might be the inconvenience of
typing. I wonder if the people who would use them are going to be typing
them anyway in other contexts.


Finally, this is even _more_ specific to mathematical use cases. If I want
> to inline a higher-order function, there will likely be no obvious
> mathematical symbol for most of them.
>

I'm not so sure about that. Check out this list of 949 Unicode math
symbols. http://www.fileformat.info/info/unicode/category/Sm/list.htm And
depending on the definition, there could be even more than that. While some
of these have strong meanings (like variations on standard mathematical
operators, integral signs, etc.) a lot seem more adaptable.

> And I probably need to write sample['∩'] not sample.∩.
>
> This part I don't like. In Python, attribute access and keyed access are
> different; namespaces are not dictionaries and vice-versa.
>
> And it argues against the quoted operator syntax (unless you want to allow
> quotes for attribute access...).
>

Oops. Of course I meant getattr(sample, '∩'). I've been switch back and
forth a lot between Python and Javascript lately and it's easy to get that
confused. Yes, that's not as attractive as sample.__add__ but do we write
this that often?

--- Bruce
Learn how hackers think: http://j.mp/gruyere-security
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140222/4e08ea63/attachment.html>


More information about the Python-ideas mailing list