The Case Against Autodecode

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 2 13:12:39 PDT 2016


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.

> 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.


More information about the Digitalmars-d mailing list