On Tuesday, 30 May 2017 at 21:16:26 UTC, Oleg B wrote:
Hello. I have this code
import std.stdio;
void foo(byte a) { writeln(typeof(a).stringof); }
void foo(short a) { writeln(typeof(a).stringof); }
void foo(int a) { writeln(typeof(a).stringof); }
void main()
{
foo(0); // int, and byte if
On Tuesday, 30 May 2017 at 21:42:03 UTC, Daniel Kozak wrote:
Compiler do many assumptions (it is sometimes useful).
but if compiler find one-to-one correspondence it don't make
assumptions, like here?
import std.stdio;
void f(ushort u)
{
writeln("ushort");
}
void f(ubyte u)
{
Dne 30.5.2017 v 23:16 Oleg B via Digitalmars-d-learn napsal(a):
Hello. I have this code
import std.stdio;
void foo(byte a) { writeln(typeof(a).stringof); }
void foo(short a) { writeln(typeof(a).stringof); }
void foo(int a) { writeln(typeof(a).stringof); }
void main()
{
foo(0); // int,
and this is unexpected for me too
immutable ushort y = 0;
foo(y); // byte
Hello. I have this code
import std.stdio;
void foo(byte a) { writeln(typeof(a).stringof); }
void foo(short a) { writeln(typeof(a).stringof); }
void foo(int a) { writeln(typeof(a).stringof); }
void main()
{
foo(0); // int, and byte if not define foo(int)
foo(ushort(0)); // byte