[Python-ideas] new operators via backquoting
Josiah Carlson
jcarlson at uci.edu
Wed Jan 3 01:52:06 CET 2007
Chris Rebert <cvrebert at gmail.com> wrote:
>
> In Haskell, foo `baz` bar means (baz foo bar), which translates to
> baz(foo, bar) in Python. This allows Haskell programmers to use
> functions as infix operators.
> If I recall correctly, in Py3k, enclosing something in backticks will no
> longer cause it to be repr()-ed, leaving the backtick without a meaning
> in Python.
[snip]
> I believe that this would improve the readability of code, such as
> Numeric, without going off the deep end and offering programmable syntax.
Let us break down what you are more or less proposing...
foo `baz` bar
... is translated into ...
foo.__baz__(bar)
bar.__rbaz__(foo)
How is that any easier to read or understand than...
baz(foo, bar)
I don't believe it is easier to understand, and would claim that it is
more difficult to understand, especially to users who have seen
backticks being used for repr. The only people it could be more
undestandable to is those who have used Haskell and have seen such
operator use in the past. I dont know how many of those users there are,
but I don't believe that the confusion would be worth it.
If you want to call a method on an object, call the method. If you want
to call a function that does automatic method invocation, that is fine
too. But what you are offering is more or less arbitrary infix
operators, which I can't see as being anything more than confusing to
new and seasoned Python users alike.
- Josiah
More information about the Python-ideas
mailing list