float init 0 request
Steven Schveighoffer
schveiguy at gmail.com
Wed Aug 19 21:17:04 UTC 2026
On Wednesday, 19 August 2026 at 19:57:57 UTC, Walter Bright wrote:
> All in all, D's semantic selections for integral types are
> better than anyone else's for type safety and convenience.
```d
foreach(dchar d; "Über") {
writeln(d);
}
foreach(dchar d; "Über".byCodeUnit) {
writeln(d);
}
```
The first prints 4 code points, each of the characters listed.
The second prints 5 code points, the first two are the *integer
promotion* of the two utf8 code units that encode "Ü" to dchar,
which is nonsense.
The second should not compile. It should be an error to
implicitly promote char to dchar. It's a nonsense conversion that
is allowed implicitly.
Promoting to int is fine. But dchar is not an int.
If you think this example is rare, wait until we remove
autodecoding.
-Steve
More information about the Digitalmars-d
mailing list