Why is string.front dchar?
Jakob Ovrum
jakobovrum at gmail.com
Mon Jan 20 08:53:30 PST 2014
On Monday, 20 January 2014 at 13:30:11 UTC, Tobias Pankrath wrote:
> (w|d)string.length returning anything else then the number of
> underlying code points would be inconsistent to other array
> types and m aking (d|w)string arrays of code points was a
> (arguably good) design decision.
Code units, not code points.
Of course, a single UTF-32 code unit is also a single code point.
> That said: nothing prevents you from writing another string
> type that abstracts from the actual string encoding.
Such types tend to have absolutely awful performance. It is a
minefield of disastrous algorithmic complexity, too (e.g. length).
> Phobos did it wrong though with handling char[] different from
> T[].
It is only for ranges, and I think it's a good decision.
More information about the Digitalmars-d-learn
mailing list