[review] new string type

Jerry Quinn jlquinn at optonline.net
Fri Dec 3 11:40:30 PST 2010


Steven Schveighoffer Wrote:

> 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.

I tend to do a lot of transforming strings, but I need to track offsets back to the original text to maintain alignment between the results and the input.  For that, indexes are necessary and we use them a lot.

Probably the right thing to do in this case is just pay for the cost of using dchar everywhere, but if you're working with large enough quantities of data, storage efficiency matters.

Jerry



More information about the Digitalmars-d mailing list