The type of an element-wise arithmetic expression

Eduardo Cavazos wayo.cavazos at gmail.com
Sat Aug 21 00:56:53 PDT 2010


Hello,

This program:

----------------------------------------------------------------------
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[] ) ;
}
----------------------------------------------------------------------

produces an error:

$ rdmd array_wise_a.d
array_wise_a.d(11): Error: function array_wise_a.f0 (double[2u] a) is 
not callable using argument types (double[])
array_wise_a.d(11): Error: cannot implicitly convert expression (a[] - 
b[]) of type double[] to double[2u]

Since the sub-expressions a[] and b[] are each of type double[2], I 
would expect the the type of a[]-b[] to also be of double[2], and thus 
compatible with f0.

Ed


More information about the Digitalmars-d mailing list