[phobos] std.ctype vs std.string
Jonathan M Davis
jmdavisProg at gmx.com
Wed May 25 14:18:10 PDT 2011
On 2011-05-25 13:19, Jesse Phillips wrote:
> Personally I have never used std.ctype and would never guess what is
> actually in there. I thought it would be more like core.stdc.types (or
> whatever it is called).
It is modeled after C's ctype.h, which I believe is meant to stand for
"character type." It holds functions for querying about the type of a
character (digit, hex digit, uppercase letter, etc.). It's all ASCII-specific.
std.uni holds what corresponding unicode functions we have. So, essentially,
std.ctype has functions for operating on ASCII characters, std.uni has
functions for operating on unicode characters, and std.string has functions
for operating on strings. std.ascii would probably be better than std.ctype,
but we already have std.ctype, and C or C++ folks may recognize it. But
std.ctype holds pure D functions (albeit based on their C counterparts -
including return int instead of bool for for true and false - though they do
take dchar, not char), so they wouldn't be in core.stdc. However, over time,
some std.string seems to have taken on some functionality which makes more
sense for std.ctype or std.uni, so they should be better organized.
I'm moving the functions which operate on dchar instead of strings to
std.ctype and std.uni (depending on whether they're ASCII-specific or deal
with unicode). I'm also fixing the names in std.string and std.ctype so that
they're properly camelcased. A previous discussion on revamping std.string a
few months ago made it quite clear that the majority want those functions (and
Phobos in general) to follow its own naming conventions consistently, and
std.string and std.ctype are two of the major places that the function names
aren't properly camelcased. So, I'm fixing that as well as trying to properly
unicodify a few of the std.string functions which are still too ASCII-
specific. All of the old functions will still be there as scheduled for
deprecation for the time being though.
- Jonathan M Davis
More information about the phobos
mailing list