Unicode operators (OT)

Paul D. Anderson paul.d.removethis.anderson at comcast.andthis.net
Wed Oct 22 20:39:09 PDT 2008


Bill Baxter Wrote:

> 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.
> >

The cross product, according to Wikipedia anyway, is also defined for 7-d vectors. (I did not know that. I'm not sure I know it now.)

But the cross product generalizes to an 'exterior' or 'wedge' product, defined in spaces of any dimension. However it no longer uses an 'x' symbol but replaces it with a wedge-shaped symbol (looks like a Greek lambda). This is a useful symbol, in its place, but I can't imagine it being useful in computing applications short of the Mathematica level.

Paul





More information about the Digitalmars-d mailing list