Higher level built-in strings

Walter Bright newshound2 at digitalmars.com
Mon Jul 19 13:04:21 PDT 2010


bearophile wrote:
> This odd post comes from reading the nice part about strings of chapter 4 of
> TDPL. In the last few years I have seen changes in how D strings are meant
> and managed, changes that make them less and less like arrays (random-access
> sequences of mutable code units) and more and more what they are at high
> level (immutable bidirectional sequences of code points).

Strings in D are deliberately meant to be arrays, not special things. Other 
languages make them special because they have insufficiently powerful arrays.

As for indexing by code point, I also believe this is a mistake. It is proposed 
often, but overlooks:

1. most string operations, such as copying and searching, even regular 
expressions, work just fine using regular indices.

2. doing the operations in (1) using code points and having to continually 
decode the strings would result in disastrously slow code.

3. the user can always layer a code point interface over the strings, but going 
the other way is not so practical.


More information about the Digitalmars-d mailing list