The Case Against Autodecode

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 2 15:16:50 PDT 2016


On 02.06.2016 23:29, Andrei Alexandrescu wrote:
> On 6/2/16 5:23 PM, Timon Gehr wrote:
>> On 02.06.2016 22:51, Andrei Alexandrescu wrote:
>>> On 06/02/2016 04:50 PM, Timon Gehr wrote:
>>>> On 02.06.2016 22:28, Andrei Alexandrescu wrote:
>>>>> On 06/02/2016 04:12 PM, Timon Gehr wrote:
>>>>>> It is not meaningful to compare utf-8 and utf-16 code units directly.
>>>>>
>>>>> But it is meaningful to compare Unicode code points. -- Andrei
>>>>>
>>>>
>>>> It is also meaningful to compare two utf-8 code units or two utf-16
>>>> code
>>>> units.
>>>
>>> By decoding them of course. -- Andrei
>>>
>>
>> That makes no sense, I cannot decode single code units.
>>
>> BTW, I guess the reason why char converts to wchar converts to dchar is
>> that the lower half of code units in char and the lower half of code
>> units in wchar are code points. Maybe code units and code points with
>> low numerical values should have distinct types.
>
> Then you lost me. (I'm sure you're making a good point.) -- Andrei

Basically:

bool bad(char c,dchar d){ return c==d; } // ideally shouldn't compile
bool good(char c,char d){ return c==d; } // should compile


More information about the Digitalmars-d mailing list