digitalmars.D - Auto-Resizing String...
- Joe Somewhere.com (18/18) May 06 2004 I have no idea if this has been posted before and can't search. But I do...
- J Anderson (7/26) May 06 2004 Hu? Why not create an alias if you don't like the name char []?
- Norbert Nemec (11/33) May 06 2004 try
- Chris Lawson (5/29) May 06 2004 Go to http://digitalmars.com/d, click on "Arrays" to the left, and
I have no idea if this has been posted before and can't search. But I don't understand why auto-resizing strings are not available in D. I mean in this day and age, string usage is an extremely common task therefore worrying about if your char array is big enough is annoying. Also, char overflows are a common problem in C and therefore something that needs addressing. So why on earth wouldn't you have a built in string type where it is impossible to overflow. It to move to D because they can get their heads around string more easily than char. The char type is also OVERLY complex. Although the char type clearly is required, it is harder to read. char[100] thingy = ""; thingy ~= Input; string thingy = ""; thingy += Input; This is not a good example but in complex code, strings are easier to read and use. I just think for a new language in 2004 to NOT include a string type is just insane.
May 06 2004
Joe Somewhere.com wrote:I have no idea if this has been posted before and can't search. But I don't understand why auto-resizing strings are not available in D. I mean in this day and age, string usage is an extremely common task therefore worrying about if your char array is big enough is annoying. Also, char overflows are a common problem in C and therefore something that needs addressing. So why on earth wouldn't you have a built in string type where it is impossible to overflow. It to move to D because they can get their heads around string more easily than char. The char type is also OVERLY complex. Although the char type clearly is required, it is harder to read. char[100] thingy = ""; thingy ~= Input; string thingy = ""; thingy += Input; This is not a good example but in complex code, strings are easier to read and use. I just think for a new language in 2004 to NOT include a string type is just insane.Hu? Why not create an alias if you don't like the name char []? Overflow? I've never had an overflow with char []. char [] are resizable strings. It's just a difference of names. Are you arguing for a name change? -- -Anderson: http://badmama.com.au/~anderson/
May 06 2004
Joe Somewhere.com wrote:I have no idea if this has been posted before and can't search. But I don't understand why auto-resizing strings are not available in D. I mean in this day and age, string usage is an extremely common task therefore worrying about if your char array is big enough is annoying. Also, char overflows are a common problem in C and therefore something that needs addressing. So why on earth wouldn't you have a built in string type where it is impossible to overflow. It would also make it easier for people from their heads around string more easily than char. The char type is also OVERLY complex. Although the char type clearly is required, it is harder to read. char[100] thingy = ""; thingy ~= Input; string thingy = ""; thingy += Input; This is not a good example but in complex code, strings are easier to read and use. I just think for a new language in 2004 to NOT include a string type is just insane.try char[] thingy = ""; thingy ~= Input; what happens internally is, that char[] is basically a char* together with the range of the array. The ~ operator allocates new space on the heap copies the content of both string there and returns a reference to that space which is then assigned to thingy. char[] bahaves just as you would expect it from a string type. If you want to, you can just to a alias char[] string; to get what you ask for.
May 06 2004
Joe Somewhere.com wrote:I have no idea if this has been posted before and can't search. But I don't understand why auto-resizing strings are not available in D. I mean in this day and age, string usage is an extremely common task therefore worrying about if your char array is big enough is annoying. Also, char overflows are a common problem in C and therefore something that needs addressing. So why on earth wouldn't you have a built in string type where it is impossible to overflow. It to move to D because they can get their heads around string more easily than char. The char type is also OVERLY complex. Although the char type clearly is required, it is harder to read. char[100] thingy = ""; thingy ~= Input; string thingy = ""; thingy += Input; This is not a good example but in complex code, strings are easier to read and use. I just think for a new language in 2004 to NOT include a string type is just insane.Go to http://digitalmars.com/d, click on "Arrays" to the left, and scroll down to the Strings section. HTH, Chris
May 06 2004