On Mon, 10 Mar 2014 16:52:27 -0400, Walter Bright <[email protected]> wrote:

On 3/10/2014 1:36 PM, Steven Schveighoffer wrote:
What strings are already is a user-defined type,

No, they are not.

The functionality added via phobos can hardly be considered extraneous. One would not use strings without the library.

but with horrible enforcement.

With no enforcement, and that is by design.

The enforcement is opt-in. That is, you have to use phobos' templates in order to use them "properly":

auto getIt(R)(R r, size_t idx)
{
   if(idx < r.length)
      return r[idx];
}

The above compiles fine for strings. However, it does not compile fine if you do:

auto getIt(R)(R r, size_t idx) if(hasLength!R && isRandomAccessRange!R)

Any other range will fail to compile for the more strict version and the simple implementation without template constraints. In other words, the compiler doesn't believe the same thing phobos does. shooting one's foot is quite easy.

Keep in mind that D is a systems programming language, and that means unfettered access to strings.

Access is fine, with clear intentions. And we do not have unfettered access. I cannot sort a mutable string of ASCII characters without first converting it to ubyte[].

What in my proposal makes you think you don't have unfettered access? The underlying immutable(char)[] representation is accessible. In fact, you would have more access, since phobos functions would then work with a char[] like it's a proper array.

-Steve

Reply via email to