Unicode operators

Bill Baxter wbaxter at gmail.com
Wed Oct 22 18:07:29 PDT 2008


Some random thoughts:

I agree it would be cool to be able to write  a × b and get a cross product.

But it would be uncool if every Unicode operator meant adding new
special opFoo and opFooAssign methods.  So this is connected to the
operator overloading overhaul.

Also cross product is rather specialized.  In all of math the cross
product operator only has meaning for 2-d and 3-d vectors as far as I
know.   The dot is used a little more widely.

The ability to define new infix operators would be generally useful
quite apart from discussions of Unicode.
If I could say    A dot B and A cross B instead of dot(A,B) that would
already be quite cool.  Uh oh, here comes Downs!  [ducks]

The classic problem with new infix operators is defining precedence.
Without precedence you can't decide what
  A op1 B op2 C
is supposed to equal.
I think it was Ocaml or something allows you to declare new infix
operators with precedence based on other operators.  So with that you
can kind of create a "subclass" of the multiply operator, that has
similar precedence.  That seems elegant to me.

--bb

On Thu, Oct 23, 2008 at 8:57 AM, Moritz Warning <moritzwarning at web.de> wrote:
> Unicode operators would be nice addition to D.
>
> Since it's common to have opFooBar style operators overloads in D,
> I would like to rise the question what unicode operators do users need
> (most) or would like to have?
>
> opDotProduct and opCrossProduct would be definitely cool.
>



More information about the Digitalmars-d mailing list