November 08, 2005
In the following sample:

----
import std.stdio;

bool t = true;
bool f = false;

void print(bool b)
{
  writefln("#B: ", b);
}

void print(bit b)
{
  writefln("#T: ", b);
}

int main()
{
  print(t);
  print(f);
  print(true);
  print(false);
}
----

compiling with DMD v0.139 on Windows XP I get:

testBool.d(18): function testBool.print called with argument types:
(bit)
matches both:
testBool.print(bit)
and:
testBool.print(bit)
testBool.d(19): function testBool.print called with argument types:
(bit)
matches both:
testBool.print(bit)
and:
testBool.print(bit)
testBool.d(20): function testBool.print called with argument types:
(bit)
matches both:
testBool.print(bit)
and:
testBool.print(bit)
testBool.d(21): function testBool.print called with argument types:
(bit)
matches both:
testBool.print(bit)
and:
testBool.print(bit)

I don't understand:

- If bool is an alias for bit, then the declaration of the two functions shoul
have failed at line 11.
- If bool is a typedef for bit, then the program should have compiled correctly.

Ciao


November 12, 2005
Roberto Mariottini schrieb am 2005-11-08:
> In the following sample:
>
> ----
> import std.stdio;
> 
> bool t = true;
> bool f = false;
> 
> void print(bool b)
> {
>   writefln("#B: ", b);
> }
> 
> void print(bit b)
> {
>   writefln("#T: ", b);
> }
> 
> int main()
> {
>   print(t);
>   print(f);
>   print(true);
>   print(false);
> }
> ----
>
> compiling with DMD v0.139 on Windows XP I get:
>
> testBool.d(18): function testBool.print called with argument types:
> (bit)
> matches both:
> testBool.print(bit)
> and:
> testBool.print(bit)
> testBool.d(19): function testBool.print called with argument types:
> (bit)
> matches both:
> testBool.print(bit)
> and:
> testBool.print(bit)
> testBool.d(20): function testBool.print called with argument types:
> (bit)
> matches both:
> testBool.print(bit)
> and:
> testBool.print(bit)
> testBool.d(21): function testBool.print called with argument types:
> (bit)
> matches both:
> testBool.print(bit)
> and:
> testBool.print(bit)
>
> I don't understand:
>
> - If bool is an alias for bit, then the declaration of the two functions shoul
> have failed at line 11.
> - If bool is a typedef for bit, then the program should have compiled correctly.

Bool is an alias for bit (-> dmd/src/phobos/object.d:6).

http://dstress.kuehne.cn/nocompile/alias_05.d

Thomas