Strings in DWT

torhu no at spam.invalid
Wed Feb 20 17:49:34 PST 2008


Frank Benoit wrote:
> Strings in Java and D are different.
> - null vs zero length is in Java completely different
> - Java works in utf16, char[] is utf8
> 
> 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.

But if it's called 'string', it'll in reality become a part of DWT's 
public api, and hard to remove later.  So I think it's good to stay away 
from that exact name unless Tango adds it.


[1]
static if(!is(string)) {
    static if(!is(typeof((new Object()).toString()) string)) {
       alias char[] string;
    }
}


More information about the Digitalmars-d-dwt mailing list