D - string documentation wrong?
- Sarat Venugopal (13/13) Oct 07 2003 The docs say:
- davepermen (6/19) Oct 07 2003 as you say, suported with ~.. so use ~instead of +
- Charles Hixson (11/28) Oct 07 2003 Two comments:
- J C Calvarese (9/32) Oct 07 2003 Comparisons (<, >, and ==) work for me. Use the ~ for appending and
- Walter (5/16) Oct 08 2003 The documentation is wrong; '~' is the concatenate operator for strings,...
The docs say: Strings can be copied, compared, concatenated, and appended: char[] str; char[] str1 = "abc"; str1 = str2; if (str1 < str3) ... func(str3 + str4); str4 += str1; with the obvious semantics. It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here? Cheers, Sarat
Oct 07 2003
as you say, suported with ~.. so use ~instead of + func(string3 ~ string4); string3 ~= string4; and similar.. not sure about the <, i have to read that up again, haven't used it yet.. In article <blv327$15gn$1 digitaldaemon.com>, Sarat Venugopal says...The docs say: Strings can be copied, compared, concatenated, and appended: char[] str; char[] str1 = "abc"; str1 = str2; if (str1 < str3) ... func(str3 + str4); str4 += str1; with the obvious semantics. It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here? Cheers, Sarat
Oct 07 2003
Sarat Venugopal wrote:The docs say: Strings can be copied, compared, concatenated, and appended: char[] str; char[] str1 = "abc"; str1 = str2; if (str1 < str3) ... func(str3 + str4); str4 += str1; with the obvious semantics. ...Two comments: 1) do be aware that D is still a work in progress. I'm never certain before I try just which language features have actually been implemented. 2) shouldn't that be str4 ~= str1 rather than str4 += str1 ? 2a) if you're missing a feature, you might be able to implement it yourself in a subclass via redefining the operation. (I admit I haven't tried this with the "array of chars" type. But for some other's it's worked well.... I say without having gotten the application to the point where I can do unit testing.)
Oct 07 2003
Sarat Venugopal wrote:The docs say: Strings can be copied, compared, concatenated, and appended: char[] str; char[] str1 = "abc"; str1 = str2; if (str1 < str3) ... func(str3 + str4); str4 += str1; with the obvious semantics. It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here? Cheers, SaratComparisons (<, >, and ==) work for me. Use the ~ for appending and concatenation. I've attached an example that works on my system. If my example doesn't help, it might be useful for you to post a complete example (whether it compiles or not). I'm running WindowsXP. I don't know if my example works on the Linux version (if it doesn't that would probably indicate a compiler bug). Hope this helps. Justin
Oct 07 2003
"Sarat Venugopal" <sarat_ng n0spam.huelix.com> wrote in message news:blv327$15gn$1 digitaldaemon.com...The docs say: Strings can be copied, compared, concatenated, and appended: char[] str; char[] str1 = "abc"; str1 = str2; if (str1 < str3) ... func(str3 + str4); str4 += str1; with the obvious semantics. It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here?The documentation is wrong; '~' is the concatenate operator for strings, not '+'. Similarly, use '~=' for append, not '+='. I've corrected the documentation.
Oct 08 2003