Types A!1 and A!1u not considered equal?

2011-10-21 Thread Tobias Brandt
Consider the following program:  class A(uint N) {}  void foo(uint N)(A!N) {}  void main()  {      auto a = new A!1;                           // compiles      foo(new A!1);                               // error      foo(new A!1u);                              // compiles      foo(cast(A!1u)

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread Gor Gyolchanyan
That's because implicit casts in D are much more strict, then those in C/C++. Such seemingly intuitive cats, e.g. from long to int are not performed due to potential loss of data. Casting from int to uint has the same effect of potential loss of data. Probably, the compile-time versions of those

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread Jonathan M Davis
On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote: That's because implicit casts in D are much more strict, then those in C/C++. Such seemingly intuitive cats, e.g. from long to int are not performed due to potential loss of data. Casting from int to uint has the same effect of

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread Gor Gyolchanyan
Unlike long - int conversions, signed - unsigned conversions are narrowing in both ways. If anything, those conversions should be even more strict. On another note, i had this thought about fundamental types. What i thought about is, making fundamental types a library solution. What? Are you out

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread Don
On 21.10.2011 02:31, Tobias Brandt wrote: Consider the following program: class A(uint N) {} void foo(uint N)(A!N) {} void main() { auto a = new A!1; // compiles foo(new A!1); // error foo(new A!1u);

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread Tobias Brandt
On 21 October 2011 10:01, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote: That's because implicit casts in D are much more strict, then those in C/C++. Such seemingly intuitive cats, e.g. from long to int are not performed due to

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread Jonathan M Davis
On Friday, October 21, 2011 12:20:02 Tobias Brandt wrote: On 21 October 2011 10:01, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote: That's because implicit casts in D are much more strict, then those in C/C++. Such seemingly intuitive

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread David Nadlinger
On 10/21/11 12:20 PM, Tobias Brandt wrote: Obviously, the conversion does happen implicitly, otherwise 'new A!1' wouldn't compile (A expects a uint as parameter). But then, why are A!1 and A!1u different types? Because of a compiler bug, and contrary to the other answers, implicit conversion

Re: Types A!1 and A!1u not considered equal?

2011-10-21 Thread kenji hara
2011/10/21 Don nos...@nospam.com: On 21.10.2011 02:31, Tobias Brandt wrote: Consider the following program:  class A(uint N) {}  void foo(uint N)(A!N) {}  void main()  {      auto a = new A!1;                           // compiles      foo(new A!1);                               //