Thread overview
BUG: Internal error: ..\ztc\out.c 1127
Feb 02, 2004
davepermen
Re: Internal error: ..\ztc\out.c 1127
Feb 02, 2004
davepermen
Feb 02, 2004
davepermen
Feb 02, 2004
C
Feb 07, 2004
Walter
Feb 07, 2004
davepermen
February 02, 2004
playing with templates and aliases, i got


February 02, 2004
damn:D wrong key..

well... playing with templates and aliased, i got

Internal error: ..\ztc\out.c 1127

in this code:

import std.c.stdio;

template max(T) {
 T max(T a,T b) {
  return a > b ? a : b;
 }
}

template Max(alias A,alias B) {
 typeof(A) Max() {
  return 0; max!(typeof(A))(A,B);
 }
}

int main(char[][] args) {
 int a = 5;
 int b = 10;
 printf("Max(%i,%i) = %i" \n,a,b,Max!(a,b)); //max!(int)(5,10));
 return getch();
}


i'd prefer to have a bether error message:D

btw, code can be reduced by much..


February 02, 2004
like this:

template Foo(alias A) {
 void Foo() {
 }
}

int main(char[][] args) {
 int a = 5;
 Foo!(a);
 return getch();
}


"davepermen" <davepermen@hotmail.com> schrieb im Newsbeitrag news:bvl2qg$2in$1@digitaldaemon.com...
> damn:D wrong key..
>
> well... playing with templates and aliased, i got
>
> Internal error: ..\ztc\out.c 1127
>
> in this code:
>
> import std.c.stdio;
>
> template max(T) {
>  T max(T a,T b) {
>   return a > b ? a : b;
>  }
> }
>
> template Max(alias A,alias B) {
>  typeof(A) Max() {
>   return 0; max!(typeof(A))(A,B);
>  }
> }
>
> int main(char[][] args) {
>  int a = 5;
>  int b = 10;
>  printf("Max(%i,%i) = %i" \n,a,b,Max!(a,b)); //max!(int)(5,10));
>  return getch();
> }
>
>
> i'd prefer to have a bether error message:D
>
> btw, code can be reduced by much..
>
>


February 02, 2004
Thats cool , wish we had a tutorial on D's templates <nudge,nudge> (
Foo!(nudge,nudge ) ? )

C
"davepermen" <davepermen@hotmail.com> wrote in message
news:bvl2sj$2op$1@digitaldaemon.com...
> like this:
>
> template Foo(alias A) {
>  void Foo() {
>  }
> }
>
> int main(char[][] args) {
>  int a = 5;
>  Foo!(a);
>  return getch();
> }
>
>
> "davepermen" <davepermen@hotmail.com> schrieb im Newsbeitrag news:bvl2qg$2in$1@digitaldaemon.com...
> > damn:D wrong key..
> >
> > well... playing with templates and aliased, i got
> >
> > Internal error: ..\ztc\out.c 1127
> >
> > in this code:
> >
> > import std.c.stdio;
> >
> > template max(T) {
> >  T max(T a,T b) {
> >   return a > b ? a : b;
> >  }
> > }
> >
> > template Max(alias A,alias B) {
> >  typeof(A) Max() {
> >   return 0; max!(typeof(A))(A,B);
> >  }
> > }
> >
> > int main(char[][] args) {
> >  int a = 5;
> >  int b = 10;
> >  printf("Max(%i,%i) = %i" \n,a,b,Max!(a,b)); //max!(int)(5,10));
> >  return getch();
> > }
> >
> >
> > i'd prefer to have a bether error message:D
> >
> > btw, code can be reduced by much..
> >
> >
>
>


February 07, 2004
"davepermen" <davepermen@hotmail.com> wrote in message news:bvl2sj$2op$1@digitaldaemon.com...
> like this:
>
> template Foo(alias A) {
>  void Foo() {
>  }
> }
>
> int main(char[][] args) {
>  int a = 5;
>  Foo!(a);
>  return getch();
> }

Looks like the compiler is failing to catch the illegal reference to the local 'a'.


February 07, 2004
exactly. (but it would be great if it would not be illegal:D)

"Walter" <walter@digitalmars.com> schrieb im Newsbeitrag news:c03aj7$h3j$3@digitaldaemon.com...
>
> "davepermen" <davepermen@hotmail.com> wrote in message news:bvl2sj$2op$1@digitaldaemon.com...
> > like this:
> >
> > template Foo(alias A) {
> >  void Foo() {
> >  }
> > }
> >
> > int main(char[][] args) {
> >  int a = 5;
> >  Foo!(a);
> >  return getch();
> > }
>
> Looks like the compiler is failing to catch the illegal reference to the local 'a'.
>
>