On Mon, Mar 10, 2014 at 12:51:46AM +0000, Nathaniel Smith wrote:
> > Thus, it would certainly be a reasonable PEP to provide a framework in
> > Python to define custom infix operators (say, operator.compose), by
> > providing a character (say: '@') and the name of a custom "magical
> > method" (say: '__composition__') that is called on the operator's
> > arguments, in the same way as operator.mul uses '*' and results in
> > calling '__mul__'.
> 
> I do not believe that it is possible to write such a PEP that would be
> acceptable to the broader Python community. (I don't even think I
> could come up with such a PEP that I would accept if I were BDFL.)
> It's a huge change to how Python works, and runs into a lot of
> practical problems (defining precedence, defining scoping, creating
> nasty couplings between parse time and eval time, etc.).
> 
> That's just my best judgement, though; if someone comes along with a
> convincing proposal then I'll certainly advocate it.

For whatever it's worth, I'd love to have more infix operators in
Python. Ideally ones that you can define dynamically. Ideally UTF-8
ones like ⊗ (typically for tensor products) and ⊕ (direct sums) which
would not create syntax conflicts. Now I can see the difficulty you
point at, so the following would already be progress:

- More infix operators defined statically. E.g. @ calling a custom
  method __composition__ as suggested by Simon.

- The possibility to define such operators in the ipython console,
  even if they don't work in code.

Other than that, I see the importance of both multiplications,
definitely prefer * for matrix multiplication, and see the conflict
with the large numerical communities where * is often used for
pointwise multiplication on arrays. Good luck!

Cheers,
                                Nicolas
--
Nicolas M. Thiéry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to