Narrow string is not a random access range

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 24 04:51:58 PDT 2012


On Wednesday, October 24, 2012 13:39:50 Timon Gehr wrote:
> You realize that the proposed solution is that arrays of code units
> would no longer be arrays of code units?

Yes and no. They'd be arrays of code units, but any operations on them which 
weren't unicode safe would require using the rep property. So, for instance, 
using ptr on them to pass to C functions would be fine, but slicing wouldn't. 
It definitely would be a case of violating the turtles all the way down 
principle, because arrays of code units wouldn't really be proper arrays 
anymore, but as long as they're treated as actual arrays, they _will_ be 
misued. The trick is doing something that's both correct and reasonably 
efficient by default but allows fully efficient code if you code with an 
understanding of unicode, and to do that, you can't have arrays of code units 
like we do now. But for better or worse, that doesn't look like it's going to 
change.

What we have right now actually works quite well if you understand the issues 
involved, but it's not newbie friendly at all.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list