The Case Against Autodecode

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 2 06:24:46 PDT 2016


On 01.06.2016 23:48, Andrei Alexandrescu wrote:
> On 06/01/2016 05:30 PM, Jack Stouffer wrote:
>> On Wednesday, 1 June 2016 at 19:52:01 UTC, Andrei Alexandrescu wrote:
>>> foreach (dchar x; a) {}
>>> The latter two do autodecoding, not coversion as the rest of the
>>> language.
>>
>> This seems to be a miscommunication with semantics. This is not
>> auto-decoding at all; you're decoding, but there is nothing "auto" about
>> it. This code is an explicit choice by the programmer to do something.
>
> No, this is autodecoding pure and simple. We can't move the goals
> whenever we don't like where the ball gets.

It does not share most of the characteristics that make Phobos' 
autodecoding painful in practice.

> The usual language rules are
> not applied for strings - they are autodecoded (i.e. there's code
> generated that magically decodes UTF surprisingly for beginners, in
> apparent violation of the language rules, and without any user-visible
> request) by the foreach statement. -- Andrei
>

Agreed.

(But implicit conversion from char to dchar is a bad language rule.)


More information about the Digitalmars-d mailing list