The Case Against Autodecode
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 1 12:52:01 PDT 2016
On 06/01/2016 03:07 PM, ZombineDev wrote:
> This is not autodecoding. There is nothing auto-magic w.r.t. strings in
> plain foreach.
I understand where you're coming from, but it actually is autodecoding.
Consider:
byte[] a;
foreach (byte x; a) {}
foreach (short x; a) {}
foreach (int x; a) {}
That works by means of a conversion short->int. However:
char[] a;
foreach (char x; a) {}
foreach (wchar x; a) {}
foreach (dchar x; a) {}
The latter two do autodecoding, not coversion as the rest of the language.
Andrei
More information about the Digitalmars-d
mailing list