1

https://stackoverflow.com/a/6044657/1165790

I was under the impression that there are two ways one can assign/call things: 1) by value (the actual bit encoding of a type is assigned/sent to a variable/function and 2) by reference (the memory address of the data's location is assigned/sent to a variable/function.

What exactly is passing a 'reference by value'?

Community
  • 1
  • 1

2 Answers2

2

What it means is that you pass the reference (essentially a pointer abstraction) the same way you would pass any other primitive: by value.

Passed by Value     Passed by reference
---------------     -------------------
Integer             Object
Reference           Object that the reference points to

Because references are passed by value, you get the same behavior as you would with anything else that is passed by value; namely, that the function to which you're passing the reference uses a copy of the reference, and not the actual reference.

So if you change the reference within the function, the original reference outside the function does not change.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • I see, it's meant to take it a level further by specifying whether the reference is passed by reference (indirect) or whether the reference is passed by value - manipulating the reference won't change the original. – Wuschelbeutel Kartoffelhuhn Sep 28 '13 at 02:46
1

This is wordplay. A reference is the memory address, or, strictly speaking, an abstraction that has all the attributes of a memory address. So to pass a reference by value is just what you said: the bits of the address are passed to the callee. In the more general way of speaking that most computer language texts use, this is exactly the same as saying the object is passed by reference.

Gene
  • 46,253
  • 4
  • 58
  • 96