Andrei Alexandrescu wrote:
Correx:

http://www.reddit.com/r/programming/comments/78rmc/allowing_unicode_operators_in_d_similarly_to/

Andrei

Andrei Alexandrescu wrote:
Please vote up before the haters take it down, and discuss:

http://www.reddit.com/r/programming/comments/78rjk/allowing_unicode_operators_in_d_similarly_to/


Andrei

Entering this debate late:

I think that operator overloading itself is syntactic sugar, and primarily exists for numerical programmers. So it's not so unreasonable to support for operator overloading which is not hugely intelligible to non-mathematicians. "Funny" operators should never be seen by anyone without a mathematical background. However, I'm not so sure how common they'd actually be.

The strongest use case seems to me to be the situation where multiple related operations exist, but only one operator is available.
The classic example is vector products, where we have:
- vector dot vector
- vector cross vector
- Elementwise product of two vectors.
But we only have one opMul. So it would be useful to have alternate multiplication signs available. Adding × (opCross) as a multiplication which is non-associative would, I think, be quite generally useful.

But, I think there aren't actually very many other operators which are easy to justify on mathematical grounds. Largely because most unary operations look quite OK when implemented as functions, and mathematicians don't have a huge number of binary operators. Other than dot product, cross product, and convolution, there's the exclusive or symbol (+ with a circle around it), and everything else is pretty obscure.

Apart from the dot and cross product, the inability to have superscripts and subscripts in variable names (and comments!) is a much bigger issue, in my experience. Oh. And the lack of an exponentiation operator. I miss the old Commodore 64 up-arrow for power <g>

If you could completely ignore keyboard and display issues, and use any unicode character as an operator, which ones would you actually use?

Reply via email to