Ceci n'est pas une char

Anders F Björklund afb at algonet.se
Thu Apr 6 12:13:35 PDT 2006


Mike Capp wrote:

> At the risk of repeating James, I do think that spelling "string" as
> "char[]"/"wchar[]" is grossly misleading, particularly to people coming from any
> other C-family language. If I was doing any serious string-handling work in D
> I'd almost certainly write a opaque String class that overloaded opIndex
> (returning dchar) to do the right thing, and optimised the underlying storage to
> suit the app's requirements.

I'm not sure that C guys would miss a string class (after all, char[]
is a lot better than the raw "undefined" char* they used to be using...)
but I do see how having an easy String class around is useful sometimes.

I even wrote a simple one myself, based on something Java-like:
http://www.algonet.se/~afb/d/dcaf/html/class_string.html
http://www.algonet.se/~afb/d/dcaf/html/class_string_buffer.html


But for wxD we use a simple char[] alias for strings, works just fine...
If the backend uses UTF-16, it will convert them at runtime when needed.
(wxWidgets can be built in a "ASCII"/UTF-8, or in "Unicode"/UTF-16 mode)

Then again it only does the occasional window title or dialog string etc

--anders



More information about the Digitalmars-d mailing list