Strings in DWT

Anders F Björklund afb at
Thu Feb 21 00:41:11 PST 2008

torhu wrote:

>> In Phobos there is an alias char[] to "string". Would that make
>> sense to be used in DWT?
>> With the helper functions in dwt.dwthelper.utils, the char[] can be 
>> used like the Java String in many cases. An alias to String would 
>> remove many replacements. And this would make merging/diffing easier.
>> 1.) "char[]"
>> 2.) alias char[] string;
>> 3.) alias char[] String;
>> What do you think? What should be used in DWT?
> If it helps with porting and updating DWT, 'String' could be added for 
> internal use.  Or maybe 'jstring', to give a unique name?
> 'string' is more problematic, since it would conflict if tango adds it 
> too, leading to some user confusion until it can be fixed.  This can of 
> course be avoided by using the trick[1] that Thomas Kuehne posted last 
> summer.

And "string" is predefined as invariant in D2, which further complicates
the matter and makes it a good idea to avoid redeclaring "string" type.
("String" would be a class normally, with the upper case letter in it ?)

wxD had a "string" type long before D did, so it's currently using some
versioning in order to only declare the type when the stdlib doesn't...
(the fully qualified name of the old alias type being wx.common.string)

version (Tango)
const int version_major = 1;
const int version_minor = 0;
else // Phobos
public import std.compiler; // version

static if (version_major < 1 ||
(version_major == 1 && version_minor < 16))
         alias char[] string; // added in DMD 1.016 and DMD 2.000

I'd go with either of the now built-into-Phobos types "string" (char[])
and "wstring" (wchar[]), or use some adapation of the java String class.
Depending on whether you want it to be an array or a class, not sure ?


More information about the Digitalmars-d-dwt mailing list