standard ranges
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jun 27 11:09:49 PDT 2012
On Wed, 27 Jun 2012 13:30:48 -0400, Jonathan M Davis <jmdavisProg at gmx.com>
wrote:
> I don't see why having the literal be a string would make anything
> confusing.
> The fact that a string is considered a range of dchar rather than char
> could
> be, but I don't see why having a string literal be a dstring instead of a
> string would help with that. Besides, it's generally expected that
> you'll use
> string for strings unless you specifically need wstring or dstring for
> some
> reason.
No, the reason is:
1. T[] is a range of T, unless T == char or T == wchar, and then it's a
range of dchar (huh?)
2. char[] is not a random access range, even though str[i] and str.length
work.
The fundamental flaw in the way this works is that phobos is pretending
immutable(char)[] is not an array. immutable(char)[] should be an array
of immutable char, string should be a *separate type* of a range of dchar,
perhaps with immutable(char)[] as its underlying storage.
D needs a full, library-defined string type. Until it has that, it's
going to cause endless confusion and WATs.
-Steve
More information about the Digitalmars-d
mailing list