May 17, 2004
Experimenting with a feature i heared about today i got to this
non-working code:
<CODE>
import std.c.stdio;

template sum(T)
{
     T sum(T[] x)
     {
          T z;
          for(int i=0;i<x.length;i++)
          {
               z+=x[i];
          }
          return z;
     }
}

alias sum!(int) sumint;

int main ( char [] [] args )
{
 static int[] ints=[1,2,3,4,5];
 printf("Sum = %d\n",ints.sumint());
 printf("Sum = %d\n",ints.sum!(int)());    //this doesn't work
 printf("Sum = %d\n",sum!(int)(ints));

 getch();
 return 1;
}
</CODE>

if I write
alias sum!(int) sumint;
then
"ints.sumint()" and "ints.sum!(int)()" should be the same!