Array operation for computing the dot product?

Chad J chadjoan at __spam.is.bad__gmail.com
Wed Feb 3 18:38:52 PST 2010


Michiel Helvensteijn wrote:
> bearophile wrote:
> 
>>> Indeed. The difficult question is, what would the syntax be?
>> What about the simper:
>> x.dot(y)
> 
> I don't like symmetric operations with an asymmetric syntax.
> 
> Better:      dot(x, y)
> Even better: dot_product(x, y)
> Funner:      sum(x .* y)
> 

Fine stuff.

This reminds me of a discussion we had a year or more ago about offering
abstract operators purely for the purpose of overloading.  We can use
things like (+), (*), (-), (&), and so on.  It'd probably be fine to use
one for dot product.  Probably a dream though.  It looks like it's very
hard to get new tokens/syntax into the language at this point.  I
suppose annotations and exponentiation managed it, but with no shortage
of blood, sweat, and tears.



More information about the Digitalmars-d mailing list