F
Flash Gordon
jameskuyper said:It's C++ - you can't stop people from writing new string classes.
However, if you don't want your algorithm to be affected by the
existence of such classes, that's trivial to arrange.
Ah, but I want to use Fred Blog's library which will take strings, so I
need it to take The One True String Type. I'll be calling some of his
functions, passing strings, and also passing functions which take
strings as parameters. Oh, and I'll be passing functions that take
references to strings, and references to strings.
Keep going.
I don't want the overhead of indirect calls normally implied by the use
of classes for what should be a basic type
I initially thought that the two different string types you were
talking about were char* and wchar_t* in C; on the basis of that
assumption, I wrote:
Well, I don't want that...
However, here it sounds like you're referring to char* and
std::string.
and I don't want that either.
In that case, keep in mind that support for char* is
mandated by the fact that one of the design objectives for C++ has
always been to remain backwards compatible with C. That objective has
occasionally been sacrificed in order to meet other objectives, but
there's no compelling need to delete support for C-style null-
terminated strings.
I agree there are good reasons for C++ supporting C style strings, and
I'm not saying it should be dropped in C++. However, such support is one
reason for using a differently language which does not have that baggage
when I would serious string processing.
Also, I don't see that it being implemented by a library (as far as user
level use is concerned) gives any benefit over a different language
where strings are a basic type in the language.