Code security: "auto" / Reason for errors

Jack Stouffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 2 18:39:56 PST 2016


On Wednesday, 2 March 2016 at 20:01:01 UTC, Ozan wrote:
> I agree for slices, but typically variables should have his own 
> data.
> To add additional code for separate data has a lot of risk in 
> my mind.
> Behaviors should also be the same.
>
> int a = 1:
> int b = a;  // data copy
>
> int[] a;
> int[] b = a; // pointer copy
>
> is not the same and should be avoid.

It seems you are being confused by the difference between 
reference and value types. See this article for an explaination 
on the difference: http://www.albahari.com/valuevsreftypes.aspx

That article is for C# but it's mostly the same behavior as D. 
Dynamic arrays are reference types in D; ints are value types.


More information about the Digitalmars-d mailing list