eliminate junk from std.string?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jan 11 15:33:18 PST 2011
On 1/11/11 1:45 PM, Jerry Quinn wrote:
> Andrei Alexandrescu Wrote:
>
>> On 1/9/11 4:51 PM, Andrei Alexandrescu wrote:
>>> There's a lot of junk in std.string that should be gone. I'm trying to
>>> motivate myself to port some functions to different string widths and...
>>> it's not worth it.
>>>
>>> What functions do you think we should remove from std.string? Let's make
>>> a string and then send them the way of the dino.
>>>
>>>
>>> Thanks,
>>>
>>> Andrei
>>
>> I have uploaded a preview of the changed APIs here:
>>
>> http://d-programming-language.org/cutting-edge/phobos/std_string.html
>
> Unclear if iswhite() refers to ASCII whitespace or Unicode. If Unicode, which version of the standard?
Not sure.
enum dchar LS = '\u2028'; /// UTF line
separator
enum dchar PS = '\u2029'; /// UTF
paragraph separator
bool iswhite(dchar c)
{
return c <= 0x7F
? indexOf(whitespace, c) != -1
: (c == PS || c == LS);
}
Which version?
> Same comment for icmp(). Also, in the Unicode standard, case folding can depend on the specific language.
That uses toUniLower. Not sure how that works.
> There is room for ascii-only functions, but unless a D version of ICU
> is going to be done separately, it would be nice to have full
> unicode-aware functions available.
Yah, I'm increasingly thinking of defining an AsciiChar entity and
perhaps a Zstring one for zero-terminated strings.
> You've got chop() marked as deprecated. Is popBack() going to make
> sense as something that removes a variable number of chars from a
> string in the CR-LF case? That might be a bit too magical.
Well I found little use for chop in e.g. Perl. People either use chomp
or want to remove the last character. I think chop is useless.
> Rather than zfill, what about modifying ljustify, rjustify, and
> center to take an optional fill character?
Yah, I wanted to do that but postponed because it's quite a bit of work
with general dchars etc.
> One set of functions I'd like to see are startsWith() and endsWith(). I find them frequently useful in Java and an irritating lack in the C++ standard library.
Yah, those are in std.algorithm. Ideally we'd move everything that's
applicable beyond strings to std.algorithm.
Andrei
More information about the Digitalmars-d
mailing list