float init 0 request

Nick Treleaven nick at geany.org
Wed Aug 19 09:55:56 UTC 2026


On Tuesday, 18 August 2026 at 19:44:49 UTC, H. S. Teoh wrote:
> D might as well use integer types for char, because char, 
> wchar, and dchar implicitly convert to non-character int types. 
>  This happens even during overload selection: func(int) is 
> preferred over func(dchar) when selecting an overload that 
> calls `func` with a wchar argument.

No:
```d
char f(int) => 'i';
char f(dchar) => 'd';

void main()
{
     import std.stdio;
     wchar w;
     w.f.writeln; // Error
}
```

```
charover.d(8): Error: `charover.f` called with argument types 
`(wchar)` matches multiple overloads after implicit conversions:
charover.d(1):     `charover.f(int __param_0)`
and:
charover.d(2):     `charover.f(dchar __param_0)`
     w.f.writeln;
      ^
```

I think implicit conversion from integer to character types is a 
more serious problem than going the other direction:
```d
     int i = 80;
     writeln("" ~ i); // prints 'P'
```


More information about the Digitalmars-d mailing list