The Case Against Autodecode

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 2 14:56:10 PDT 2016


On 6/2/2016 1:12 PM, Timon Gehr wrote:
> On 02.06.2016 22:07, Walter Bright wrote:
>> On 6/2/2016 12:05 PM, Andrei Alexandrescu wrote:
>>> * s.all!(c => c == 'รถ') works only with autodecoding. It returns
>>> always false
>>> without.
>>
>> The o is inferred as a wchar. The lamda then is inferred to return a
>> wchar.
>
> No, the lambda returns a bool.

Thanks for the correction.


>> The algorithm can check that the input is char[], and is being
>> tested against a wchar. Therefore, the algorithm can specialize to do
>> the decoding itself.
>>
>> No autodecoding necessary, and it does the right thing.
>
> It still would not be the right thing. The lambda shouldn't compile. It is not
> meaningful to compare utf-8 and utf-16 code units directly.

Yes, you have a good point. But we do allow things like:

    byte b;
    if (b == 10000) ...



More information about the Digitalmars-d mailing list