Programming Thread

Viewing single post

Started by the-pi-guy, Mar 13, 2016, 10:39 PM

previous topic - next topic

Legend

In PL we are learning about different ways to pass parameters.  

f(a,b){
b=a+b;
}

main(){
int a=1, b=2
f(a,b);
print(a, b)
}

by value: 1 2
by reference: 1 3
copy by value: 1 3
macro: 1 3

You can get wildly different answers, just depending on how things are evaluated.

I was so confused when I first started realising arrays in C# were passed by reference instead of by value. At that time I only thought it happened to objects.