The type of an element-wise arithmetic expression

bearophile bearophileHUGS at lycos.com
Sat Aug 21 04:50:17 PDT 2010


Eduardo Cavazos:
> import std.stdio ;
> 
> void f0 ( double [2] a ) { writeln ( a ) ; }
> 
> void main ()
> {
>    double [2] a = [ 1.0 , 2.0 ] ;
>    double [2] b = [ 3.0 , 4.0 ] ;
> 
>    f0 ( a[] - b[] ) ;
> }

I am not sure this code is supported. I think that currently the right way to use array ops is to give a wide enough as lvalue. But note this syntax can't be used (I have a bug report on this too) (the usage of [] has to become obligatory):

double[2] c[] = a[] - b[];

So you need to use something like:
double[2] c = void;
c[] = a[] - b[];

Bye,
bearophile


More information about the Digitalmars-d mailing list