Why not extend array operations to full Fortran90 power ?
Timon Gehr
timon.gehr at gmx.ch
Wed Nov 16 12:46:20 PST 2011
On 11/16/2011 08:08 PM, Joachim Wuttke <j.wuttke at fz-juelich.de> wrote:
> Compare
>
> (1) Y[] = X[]*X[];
> (2) Y[] = sin( X[] );
>
> With gdc 4.4.6,
> (1) compiles and executes as I expected, whereas
> (2) is not allowed (fails at compile time).
> Why?
>
> The semantics of (2) is unambiguous,
> and it works perfectly well in Fortran90.
> Allowing (2) would make D really attractive
> for formula-heavy mathematical work.
>
> - Joachim
>
I like it, but there is a problem:
(2) is already valid code if you have these two overloads:
float sin(float x);
float[] sin(float[] x);
So with your rule it would be ambiguous.
More information about the Digitalmars-d
mailing list