Thread overview
Re: Dynamic arrays in D 1.0
May 11, 2008
bearophile
May 11, 2008
Edward Diener
May 11, 2008
Tower Ty
May 11, 2008
Robert Fraser
May 11, 2008
Bill Baxter
May 11, 2008
bearophile
May 11, 2008
Edward Diener:
> I see the Phobos std.string. It seems, at first glance, not nearly as rich an implementation as the C++ std::string functionality.

A module of strings functions and the like is a work of the art of balance. More isn't always better. You have to put there the best/right functions, and throw away the useless ones, the more confusing ones, etc etc.

Bye,
bearophile
May 11, 2008
bearophile wrote:
> Edward Diener:
>> I see the Phobos std.string. It seems, at first glance, not nearly as rich an implementation as the C++ std::string functionality.
> 
> A module of strings functions and the like is a work of the art of balance. More isn't always better. You have to put there the best/right functions, and throw away the useless ones, the more confusing ones, etc etc.

I am one of those who really likes the C++ std::string class. I would not have chosen all the redundancy with C strings in the various functionality, since a std::string can always be constructed from a C string, but other than that I think it is excellent. I don't understand why D would not have wanted to create a std.string which mirrors that functionality, leaving out the C-isms except for construction. Maybe I will just do it myself and post it somewhere as I play around with D some more.

I think D has sometime tried not to be C++ to its detriment, and this is one more case of that ( there are plenty others ).
May 11, 2008
Edward Diener Wrote:

> bearophile wrote:
> > Edward Diener:
> >> I see the Phobos std.string. It seems, at first glance, not nearly as rich an implementation as the C++ std::string functionality.
> > 
> > A module of strings functions and the like is a work of the art of balance. More isn't always better. You have to put there the best/right functions, and throw away the useless ones, the more confusing ones, etc etc.
> 
> I am one of those who really likes the C++ std::string class. I would not have chosen all the redundancy with C strings in the various functionality, since a std::string can always be constructed from a C string, but other than that I think it is excellent. I don't understand why D would not have wanted to create a std.string which mirrors that functionality, leaving out the C-isms except for construction. Maybe I will just do it myself and post it somewhere as I play around with D some more.
> 
> I think D has sometime tried not to be C++ to its detriment, and this is one more case of that ( there are plenty others ).

I use tango and D1 but I for one would like to see strings available as a type rather than char[] which I just find confusing . So if you create a better string please do it in tango also.

I think there may be something there already but I havn't had time to investigate.
May 11, 2008
bearophile wrote:
> Edward Diener:
>> I see the Phobos std.string. It seems, at first glance, not nearly as rich an implementation as the C++ std::string functionality.
> 
> A module of strings functions and the like is a work of the art of balance. More isn't always better. You have to put there the best/right functions, and throw away the useless ones, the more confusing ones, etc etc.

How does std.string measure up to your standards?  No "erase" function for removing a subrange efficiently, but yet it contains "soundex()"?

--bb
May 11, 2008
Bill Baxter:
> How does std.string measure up to your standards?  No "erase" function for removing a subrange efficiently, but yet it contains "soundex()"?

I am not an expert of string APIs yet, but I have already posted here few lists of comments, where I have expressed some of my comments. I think std.string:
- Sometimes it's good enough
- it has 1-3 functions that I think can be removed/renamed
- will enjoy some general array algorithms instead of just string ones, it may mean some functions can be generalized and moved elsewhere (like Tango has done, I think).
- a better unicode management may be in order
- a lazy xslice function plus few other may be added, see my d.string module in my d libs for some functions I think are missing.
- Most functions are slow and they can improved, for example see my string module again for a _much_ faster case-changing function. And Tango shows that it's positive to give you optional ways to avoid heap activity.

Bye,
bearophile
May 11, 2008
Tower Ty wrote:
> Edward Diener Wrote:
> 
>> bearophile wrote:
>>> Edward Diener:
>>>> I see the Phobos std.string. It seems, at first glance, not nearly as rich an implementation as the C++ std::string functionality.
>>> A module of strings functions and the like is a work of the art of balance. More isn't always better. You have to put there the best/right functions, and throw away the useless ones, the more confusing ones, etc etc.
>> I am one of those who really likes the C++ std::string class. I would not have chosen all the redundancy with C strings in the various functionality, since a std::string can always be constructed from a C string, but other than that I think it is excellent. I don't understand why D would not have wanted to create a std.string which mirrors that functionality, leaving out the C-isms except for construction. Maybe I will just do it myself and post it somewhere as I play around with D some more.
>>
>> I think D has sometime tried not to be C++ to its detriment, and this is one more case of that ( there are plenty others ).
> 
> I use tango and D1 but I for one would like to see strings available as a type rather than char[] which I just find confusing . So if you create a better string please do it in tango also.
> 
> I think there may be something there already but I havn't had time to investigate.

There's mtext: http://www.dprogramming.com/mtext.php