Variable assignment
okibi
okibi at ratedo.com
Tue Mar 27 04:11:06 PDT 2007
That was exactly my problem! Now, why did it work with dmd 1.00 and not 1.006+? Did the method change within that time? I don't remember having to do this before.
Derek Parnell Wrote:
> This sounds like you are doing this, in effect.
>
> char[] var1;
> char[] var2;
>
> var1 = filename;
> . . .
> filename = something;
> . . .
> var2 = filename;
> . . .
> // Now var1 == var2;
>
> If so, then remember that assigning to an array only makes both arrays
> point to the same data in RAM. If you later change that source array in a
> way that doesn't make it allocate new RAM, you still have both vars
> pointing to the same RAM.
>
> Try ".dup" if you really need to assign data from an array rather than copy
> the reference.
>
> char[] var1;
> char[] var2;
>
> var1 = filename.dup;
> . . .
> filename = something.dup;
> . . .
> var2 = filename.dup;
> . . .
> // Now var1 != var2;
>
> --
> Derek Parnell
> Melbourne, Australia
> "Justice for David Hicks!"
> skype: derek.j.parnell
More information about the Digitalmars-d-bugs
mailing list