Thread overview | |||||
---|---|---|---|---|---|
|
January 27, 2004 operator+ and arrays | ||||
---|---|---|---|---|
| ||||
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 Re: operator+ and arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | "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 Re: operator+ and arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "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 > > > > > > > > |
Copyright © 1999-2021 by the D Language Foundation