On Mon, 22 Nov 2010 12:07:55 -0500, Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:

On 11/22/10 9:37 AM, Steven Schveighoffer wrote:
On Sun, 21 Nov 2010 23:56:17 -0500, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:

If you want to work with arrays, use a[0] to access the front, a[$ -
1] to access the back, and a = a[1 .. $] to chop off the first element
of the array. It is not AT ALL natural to mix those with a.front,
a.back etc. It is not - why? because std.range defines them with
specific meanings for arrays in general and for arrays of characters
in particular. If you submit to use std.range's abstraction, you
submit to using it the way it is defined.

I want to use char[] as an array. I want to sort the array, how do I do
this? (assume array.sort as a property is deprecated, as it should be)

Why do you want to sort an array of char?

You're dodging the question. You claim that if I want to use it as an array, I use it as an array, if I want to use it as a range, use it as a range. I'm simply pointing out why you can't use it as an array -- because phobos treats it as a bidirectional range, and you can't force it to do what you want.

More points -- what about a redblacktree!(char)? Is that 'invalid'? I mean, it's automatically sorted, so what should I do, throw an error if you try to build one? Is an Array!char a string? What about an SList!char?

The thing is, *only* when one wants to create strings, does one want to view the data type as a bidirectional string. When one wants to deal with chars as an element of a container, I don't want to be restricted to utf requirements.

FWIW, I deal in ASCII pretty much exclusively, so sorting an array of char is not out of the question. You might say "oh, well that's stupid!" but then so is using the index operator on a char[] array, no? I see no difference.

I'm going to drop out of this discussion in order to develop a viable alternative to using arrays to represent strings. Then we can discuss the merits/drawbacks of such a type. I think it will be simple to build.

-Steve

Reply via email to