Should we add `a * b` for vectors?
jmh530
john.michael.hall at gmail.com
Mon Sep 25 04:00:11 UTC 2017
On Monday, 25 September 2017 at 01:08:35 UTC, Nicholas Wilson
wrote:
>
> There's nothing stopping someone writing a DIP to include `@`
> (and possibly `#`) as overloadable binary operators.
I actually like * for dot product and matrix multiplication...
The issue is that if you use * for these, then you can't use it
for element-wise multiplication. Numpy arrays (but not matrices)
use * and / for element-wise multiplication and division. To do
matrix multiplication with Numpy arrays, you used to have to use
the dot function. This is they decided to introduce @ to the
language, b/c users didn't want to write dot all over the place.
A very popular language with a wide range of uses had to
introduce a new operator to the language because of design
choices of its most popular linear algebra library. So it makes
sense to think about these issues a bit.
> All other characters on the standard keyboard are used I think.
What about forward slash '\' (for inverse)? That is currently
used for string literals, but I can't think of a binary use right
now.
More information about the Digitalmars-d
mailing list