It would actually be of substantial benefit to readability if you *could*
overload operators for numeric, vector, and matrix-like types. In
particular, I'd strongly prefer if SIMD types, if added, *did* use
overloaded operators similarly to the BigInt proposal - it's honestly
ridiculous why people use SIMD intrinsics for things that equate to vector
addition (in the math sense).

In particular, here's a couple examples of what I mean from a math
standpoint:

Vector (3D point) addition:

<a, b, c> + <x, y, z> = <a+x, b+y, c+z>

Matrix multiplication (2D):

[a, b]    [x, y]
[c, d] × [z, w] =

[ax+bz, ax+bw]
[cx+dz, cx+dw]

Complex number division:

(a + bi) ÷ (c + di) =

(ac+bd) + i(bc - ad)
--------------------------------
           c²+d²

Set symmetric difference (i.e. exclusive or):

{1, 2, 3} ⊕ {1, 2, 4} = {3, 4}

I'd strongly prefer an operator variant over any method version, because it
matches the math notation much better. You shouldn't actually need to learn
some naming idiom just to add two things.

On Fri, Jul 14, 2017, 04:49 kai zhu <kaizhu...@gmail.com> wrote:

> > No. It is a solution to a problem I have today: arithmetic on decimal
> values.
>
> would you enjoy debugging someone else’s production-code with overloaded
> decimal operators? or would you prefer them having the courtesy to use
> method-calls, thus saving the headache of having to inspect every
> arithmetic expression?
>
> > On Jul 14, 2017, at 4:30 PM, Bruno Jouhier <bjouh...@gmail.com> wrote:
> >
> > > javascript operator-overloading is a solution in search of a problem.
> >
> > No. It is a solution to a problem I have today: arithmetic on decimal
> values.
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss@mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to