[review] new string type

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 3 10:29:26 PST 2010


On Fri, 03 Dec 2010 11:15:36 -0500, spir <denis.spir at gmail.com> wrote:

> On Thu, 02 Dec 2010 16:24:03 -0500
> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote:
>
>> Yes, it does seem odd, but then again, how often do you need the
>> individual characters of a string?  I wrote php code for about 6 months  
>> as
>> a full time job before I found I needed to access individual characters,
>> and then I had to look up how to do it :)  It's just not a common thing.
>
> Well, I wonder whether I have ever written any piece of code without  
> string indexing ;-)
> Surely depends on your app domain(s)...

Indexing a string is rare, unless you are parsing something (yes it does  
truly depend on the domain), but even rarer is indexing a string based on  
a hard-coded value.  Really, this last case is where the type would behave  
in a confusing way.

Consider that D's current's strings have even more of a limited means of  
indexing -- you can only validly index a string using an index where a  
code-point is encoded as a single code-unit.  Accessing other indexes  
(even ones that start a multi-unit code-point) results in invalid  
characters.

-Steve


More information about the Digitalmars-d mailing list