The Case Against Autodecode

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri May 13 09:05:21 PDT 2016


On 5/12/16 4:15 PM, Walter Bright wrote:

> 10. Autodecoded arrays cannot be RandomAccessRanges, losing a key
> benefit of being arrays in the first place.

I'll repeat what I said in the other thread.

The problem isn't auto-decoding. The problem is hijacking the char[] and 
wchar[] (and variants) array type to mean autodecoding non-arrays.

If you think this code makes sense, then my definition of sane varies 
slightly from yours:

static assert(!hasLength!R && is(typeof(R.init.length)));
static assert(!is(ElementType!R == R.init[0]));
static assert(!isRandomAccessRange!R && is(typeof(R.init[0])) && 
is(typeof(R.init[0 .. $])));

I think D would be fine if string meant some auto-decoding struct with 
an immutable(char)[] array backing. I can accept and work with that. I 
can transform that into a char[] that makes sense if I have no use for 
auto-decoding. As of today, I have to use byCodePoint, or 
.representation, etc. and it's very unwieldy.

If I ran D, that's what I would do.

-Steve


More information about the Digitalmars-d mailing list