D - Static vs. dynamic arrays
- tony aplawrence.com (20/20) Apr 19 2004 I saw the Slashdot article, visited the web site, and was interested eno...
- J Anderson (7/12) Apr 19 2004 Yeah there are allot of these minor consistency problems with arrays
- Russ Lewis (3/30) Apr 19 2004 I tried it on Linux, and got a segfault. Looks like a bug to me.
I saw the Slashdot article, visited the web site, and was interested enough to download the Linux compiler and start playing. Right away, I ran into confusion: dynamic arrays don't work like static arrays. For example, I can do: char [] s3="ABCDEFGH"; char [5] s4="01234"; //... s4[0..2]=s3[0..2]; but not char [] s3="ABCDEFGH"; char [] s4="01234"; //... s4[0..2]=s3[0..2]; Seeems wrong to me to have types that seem identical when you see them in code but in fact aren't?? One of the advantages listed at http://www.digitalmars.com/d/sdwest/index.html is "removal of special cases". Sure looks like a special case to me, and one the compiler isn't even aware of: the code complils, but seg faults. I'm still playing; there's enough good stuff here that I'm not turned off. This is just a minor gripe, or I stupidly missed something obvious.
Apr 19 2004
tony aplawrence.com wrote:I saw the Slashdot article, visited the web site, and was interested enough to download the Linux compiler and start playing. Right away, I ran into confusion: dynamic arrays don't work like static arrays. For example, I can do:Yeah there are allot of these minor consistency problems with arrays (you can't do operations on them yet either). With things like this, I think the programmer should be able to do what they expect to be able to do. I've a feeling (and hoping) that Walter will fix these up before 1.0. -- -Anderson: http://badmama.com.au/~anderson/
Apr 19 2004
I tried it on Linux, and got a segfault. Looks like a bug to me. Russ tony aplawrence.com wrote:I saw the Slashdot article, visited the web site, and was interested enough to download the Linux compiler and start playing. Right away, I ran into confusion: dynamic arrays don't work like static arrays. For example, I can do: char [] s3="ABCDEFGH"; char [5] s4="01234"; //... s4[0..2]=s3[0..2]; but not char [] s3="ABCDEFGH"; char [] s4="01234"; //... s4[0..2]=s3[0..2]; Seeems wrong to me to have types that seem identical when you see them in code but in fact aren't?? One of the advantages listed at http://www.digitalmars.com/d/sdwest/index.html is "removal of special cases". Sure looks like a special case to me, and one the compiler isn't even aware of: the code complils, but seg faults. I'm still playing; there's enough good stuff here that I'm not turned off. This is just a minor gripe, or I stupidly missed something obvious.
Apr 19 2004