Proposal for fixing dchar ranges

Johannes Pfau nospam at example.com
Mon Mar 10 11:49:04 PDT 2014


Am Mon, 10 Mar 2014 11:30:07 -0700
schrieb Walter Bright <newshound2 at digitalmars.com>:

> On 3/10/2014 6:35 AM, Steven Schveighoffer wrote:
> > An idea to fix the whole problems I see with char[] being treated
> > specially by phobos: introduce an actual string type, with char[]
> > as backing, that is a dchar range, that actually dictates the rules
> > we want. Then, make the compiler use this type for literals.
> 
> Proposals to make a string class for D have come up many times. I
> have a kneejerk dislike for it. It's a really strong feature for D to
> have strings be an array type, and I'll go to great lengths to keep
> it that way.

Question: which type T doesn't have slicing, has an ElementType of
dchar, has typeof(T[0]).sizeof == 4, ElementEncodingType!T == char and
still satisfies isArray?

It's a string. Would you call that 'an array type'?

	writeln(isArray!string);   //true
	writeln(hasSlicing!string); //false
	writeln(ElementType!string.stringof); //dchar
	writeln(ElementEncodingType!string.stringof); //char

I wouldn't call that an array. Part of the problem is that you want
string to be arrays (fixed size elements, direct indexing) and Andrei
doesn't want them to be arrays (operating on code points => not fixed
size => not arrays).


More information about the Digitalmars-d mailing list