typeof(string.front) should be char

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Mar 3 13:45:53 PST 2012


On Sat, Mar 03, 2012 at 11:53:41AM -0800, Jonathan M Davis wrote:
[...]
> If you want to iterate by char, then use foreach or use a wrapper
> range (or cast to ubyte[] and operate on that).

Or use:

	string str = ...;
	for (size_t i=0; i < str.length; i++) {
		/* do something with str[i] */
	}


> Phobos specificically does not to do that, because it breaks unicode.
> It doesn't stop you from iterating by char or wchar if you really want
> to, but it operates or ranges of dchar by default, because it's more
> correct.
[...]

I think this is the correct approach. Always err on the side of correct
and/or safe, but give the programmer the option of getting under the
hood if he wants otherwise.


T

-- 
A linguistics professor was lecturing to his class one day.
"In English," he said, "A double negative forms a positive. In some
languages, though, such as Russian, a double negative is still a
negative. However, there is no language wherein a double positive can
form a negative."
A voice from the back of the room piped up, "Yeah, yeah."


More information about the Digitalmars-d-learn mailing list