May 09, 2008 [Issue 2086] New: Describe relationship between string and char[] more explicitly | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2086 Summary: Describe relationship between string and char[] more explicitly Product: D Version: 2.012 Platform: PC URL: http://digitalmars.com/d/2.0/arrays.html OS/Version: Linux Status: NEW Severity: normal Priority: P3 Component: www.digitalmars.com AssignedTo: bugzilla@digitalmars.com ReportedBy: jlquinn@optonline.net This is in response to bug 2082 (and 2083, filed by accident, sorry). Since transparent assigning between string and char won't work, it would be good to update the docs to be clear about this. First, there should be language on this page saying that the string type is invariant(char[]). Next, it would be good to give examples of going between the two, since this is going to happen relatively often in string handling code if people use the string type. Some suggestions (adding on to what's there): char[] str1 = "abc"; // error, "abc" is not mutable char[] str2 = "abc".dup; // ok, make mutable copy invariant(char)[] str3 = "abc"; // ok string s1 = "abc"; // ok string s2 = str1; // error, s2 is not mutable string s3 = str1.idup; // ok, make invariant copy Another suggestion I'd like to see is to have strings at least mentioned on the types page. Even though they are really arrays, I suspect newcomers (speaking from experience) will look to the types page first to find strings. If there was a mention of strings with a link to the appropriate spot on the arrays page, I think it would ease the transition period for new developers. One other related thought - this page might not be the right place for it, but it might be nice to have an analogy drawn to Java. D string is similar to Java String and D char[] is somewhat similar to Java StringBuffer in terms of how they might be used. -- |
May 22, 2008 [Issue 2086] Describe relationship between string and char[] more explicitly | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2086 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from bugzilla@digitalmars.com 2008-05-22 05:06 ------- Fixed dmd 1.030 and 2.014 -- |
Copyright © 1999-2021 by the D Language Foundation