Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 19, 2004 Static vs. dynamic arrays | ||||
---|---|---|---|---|
| ||||
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. |
April 19, 2004 Re: Static vs. dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to tony | 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/ |
April 19, 2004 BUG: Re: Static vs. dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to tony | 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.
|
Copyright © 1999-2021 by the D Language Foundation