float init 0 request
Steven Schveighoffer
schveiguy at gmail.com
Thu Aug 20 21:46:24 UTC 2026
On Thursday, 20 August 2026 at 00:37:53 UTC, Walter Bright wrote:
> On 8/19/2026 2:17 PM, Steven Schveighoffer wrote:
>> ```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.
>
> It does what it says on the box - gives 5 code units.
It does not. Given the first statement's behavior, you would
expect `dchar` type to mean *re-encode*, as this is what it is
doing (this is a special compiler-generated decoding feature).
But any char element type other than char arrays int promotes.
Subtle changes in meaning for the same syntax are bug factories.
This is why I really like `~` being the concat operator instead
of `+`.
If integer promotion to dchar didn't work, then you would know
immediately what the problem is.
-Steve
More information about the Digitalmars-d
mailing list