Robert Jacques wrote: > On Thu, 06 May 2010 14:40:17 -0400, bearophile <bearophileh...@lycos.com> > wrote: >> Kagamin: >>> Since sin's result is not an array,< >> >> I am not sure, but I presume here Don was talking about a dispatch of >> the sin to all items of an array, so its result is another (new or >> mutated in place) array. >> >> Bye, >> bearophile >> > > That presumes a transform of the form: sin(y[]) => map!sin(y). However, > this creates unnecessary temporaries which are one of the main things > array ops is supposed to avoid. So this is a vote against sin(y[])[].
There is another use for array ops as well, that is to create a nice syntax for doing the same operation over all elements in an array. Matlab is doing this in a very nice way and it is far from all uses that requiers optimal speed. I personaly is very much in favour of allowing this transformations. Sometimes they make code much shorter to write. > Also, if sin(y[]) returned a lazy/eager array then auto t = sin(y[]); > should be valid, but auto t = x[] + y[] is not currently valid. So this is > a vote against sin(y[])[]. > > As a related note, what do people think of array ops for generic ranges > (assuming they support length, etc)? Sounds nice