2086 – Describe relationship between string and char[] more explicitly

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2086 - Describe relationship between string and char[] more explicitly
Summary: Describe relationship between string and char[] more explicitly
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: x86 Linux
: P3 normal
Assignee: Walter Bright
URL: http://digitalmars.com/d/2.0/arrays.html
Keywords:
Depends on:
Blocks:
Reported: 2008年05月09日 08:36 UTC by Jerry Quinn
Modified: 2021年02月01日 03:03 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2008年05月09日 08:36:01 UTC
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.
Comment 1 Walter Bright 2008年05月22日 05:06:01 UTC
Fixed dmd 1.030 and 2.014
Comment 2 Dlang Bot 2021年02月01日 03:03:07 UTC
dlang/dub pull request #2087 "Fix #2086 copyFiles in subPackage does not honour targetPath." was merged into master:
- d9ef71bccead54949cc83bdbde3a8b00ac87cc88 by Bastiaan Veelo:
 Fix issue #2086: Copy files of sub packages to the target path.
https://github.com/dlang/dub/pull/2087 


AltStyle によって変換されたページ (->オリジナル) /