Julia lets you define new infix operators directly, including using
mathematical symbols as operators. Not that I think that is a good idea,
but you can do it.

On Jun 3, 2017 2:00 AM, "Joshua Morton" <joshua.morto...@gmail.com> wrote:

For reference, haskell is perhaps the closest language to providing
arbitrary infix operators, and it requires that they be surrounded by
backticks. That is

    A `op` B

is equivalent to

    op(A, B)

That doesn't work for python (backtick is taken) and I don't think anything
similar is a good idea.

On Sat, Jun 3, 2017 at 1:56 AM Chris Angelico <ros...@gmail.com> wrote:

> On Sat, Jun 3, 2017 at 3:42 PM, Pavol Lisy <pavol.l...@gmail.com> wrote:
> > Sorry for probably stupid question! Is something like ->
> >
> >     class A:
> >         def __oper__(self, '⊞', other):
> >             return something(self.value, other)
> >
> >     a = A()
> >     a ⊞ 3
> >
> > thinkable?
>
> No, because operators need to be defined before you get to individual
> objects, and they need precedence and associativity. So it'd have to
> be defined at the compiler level.
>
> Also, having arbitrary operators gets extremely confusing. It's not
> easy to reason about code when you don't know what's even an operator.
>
> Not a stupid question, but one for which the answer is "definitely not
> like that".
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to