Call by reference, value, and name -


i'm trying understand conceptual difference between call reference, value, , name.

so have following pseudocode:

foo(a, b, c) {    b =b++;    = a++;    c = + b*10 }  x=1; y=2; z=3; foo(x, y+2, z); 

what's x, y, , z after foo call if a, b, , c call reference? if a, b, , c call-by-value/result? if a, b, , c call-by-name?

another scenario:

x=1; y=2; z=3; foo(x, y+2, x); 

i'm trying head start on studying upcoming final , seemed review problem go over. pass-by-name foreign me.

when pass parameter value, copies value within function parameter , whatever done variable within function doesn't reflect original variable e.g.

foo(a, b, c) {    b =b++;    = a++;    c = + b*10 }  x=1; y=2; z=3; foo(x, y+2, z); //printing print unchanged values because variables sent value //changes made variables in foo doesn't affect original. print x; //prints 1 print y; //prints 2 print z; //prints 3 

but when send parameters reference, copies address of variable means whatever variables within function, done @ original memory location e.g.

foo(a, b, c) {    b =b++;    = a++;    c = + b*10 }  x=1; y=2; z=3; foo(x, y+2, z);  print x; //prints 2 print y; //prints 5 print z; //prints 52 

for pass name; pass-by-name


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -