array operations enhancements

Don nospam at nospam.com
Wed Aug 18 22:54:51 PDT 2010


F. Almeida wrote:
> It is an excellent feature of D2 that one can do
> 
> double a[];
> double b[];
> double c[];
> 
> //...
> 
> c = a[] + 2.0*b[];
> 
> But this is still limited, as we cannot include function calls in
> these operations.
> 
> What if the compiler was able to introduce them in the assignment
> loop, provided that the functions pass ref double (in this case)?
> 
> double anyfun(ref double x) { ... }
> 
> c = anyfun(a[]) + 2.0*b[];

It's not terribly obvious to me that the 'ref' means 'this function can 
be parallelized'. Also, the function needs to be marked as pure.
Otherwise, that's an interesting syntax.
I do think we need a solution to this, so it's good to keep thinking 
about. It may be that, for example:

a[] = x * sin(b[])[] + y * cos(b[])[];

will be enough.


More information about the Digitalmars-d mailing list