Thread overview
operator+ and arrays
Jan 27, 2004
Ben Hinkle
Jan 28, 2004
Walter
Jan 28, 2004
Ben Hinkle
January 27, 2004
In the doc for the + operator it says:

"For the + operator, if both operands are arrays of a compatible type, the resulting type is an array of that compatible type, and the resulting value is the concatenation of the two arrays."

Why support this when there is the ~ operator? I would expect array + to try to add element-wise - as should all artithmetic operations. Or it should error.

-Ben



January 28, 2004
"Ben Hinkle" <bhinkle4@juno.com> wrote in message news:bv5plg$1s6a$1@digitaldaemon.com...
> In the doc for the + operator it says:
>
> "For the + operator, if both operands are arrays of a compatible type, the resulting type is an array of that compatible type, and the resulting
value
> is the concatenation of the two arrays."

The doc is wrong. I'll fix it.

> Why support this when there is the ~ operator? I would expect array + to
try
> to add element-wise - as should all artithmetic operations. Or it should error.
>
> -Ben
>
>
>


January 28, 2004
"Walter" <walter@digitalmars.com> wrote in message news:bv7jl6$1u97$2@digitaldaemon.com...
>
> "Ben Hinkle" <bhinkle4@juno.com> wrote in message news:bv5plg$1s6a$1@digitaldaemon.com...
> > In the doc for the + operator it says:
> >
> > "For the + operator, if both operands are arrays of a compatible type,
the
> > resulting type is an array of that compatible type, and the resulting
> value
> > is the concatenation of the two arrays."
>
> The doc is wrong. I'll fix it.

OK. I just tried it and it errors. Adding vectorized arithmentic ala Fortran, S or MATLAB would, I think, be really great but I can see how it could wait. The biggest problem with vectorized math in C/C++ is the memory management since the result array is implicitly allocated - but that is a non-issue with GC.

> > Why support this when there is the ~ operator? I would expect array + to
> try
> > to add element-wise - as should all artithmetic operations. Or it should error.
> >
> > -Ben
> >
> >
> >
>
>