Evaluation that bounds the resulting value to the corresponding variable in the function (frequently copying the value into a new memory region).
Questions tagged [call-by-value]
95 questions
1
vote
1 answer
Instantiating a Java Object to the passed Object Reference
this is the test code I am using to understand how java handles object memory.
public class TestCode {
public static void main(String[] args) {
TestCode obj = new TestCode();
CustomClass cs1 = new CustomClass(5);
…

Rito
- 3,092
- 2
- 27
- 40
1
vote
0 answers
call by value/call by reference assembly
I am currently learning about stack, stackframes and call by value/call by reference in assembly. The one thing, I dont understand is, what are the advantages of passing a value by reference, because how i understand it, the adresses of the values…

Hungryapeman
- 11
- 2
1
vote
0 answers
How come def processes *args in the call is alway a tuple?
This is my code. I was observing data type of args in def function.
>>> def example(a,b=None,*args,**kwargs):
... print a, b
... print args
... print kwargs
...
>>> example(1,"var",2,3,word="hello")
1 var
(2, 3)
{'word': 'hello'}
>>> _args =…
user4581250
1
vote
1 answer
Why macro function isn't call by value?
#include
#define exch(A,B) {int t=A;A=B;B=t;}
int main(void)
{
int a=1,b=4;
exch(a,b);
printf("%d\t%d\n",a,b);
return 0;
}
Prints:a=4,b=1
In the output, a and b have been exchanged; why is a macro not call by value? Please…

Chandler's Sexyface
- 75
- 2
- 5
1
vote
1 answer
Call by name/reference/value
Can someone explain call by name, reference, and value in depth and also compare them to each other?
Simple examples would be great as well. I am really focused on call by name, it feels like it's very similar to call by reference.

Jay Velasco
- 79
- 1
- 8
1
vote
3 answers
Confusion in the c code
I have a doubt in this code that why does the values that i give in the readMat() actually get stored in a and b??
I mean isn't this call by value and not by reference?
Oh if there is any other thing i am doing wrong please tell me. I will be…

user2696751
- 29
- 3
1
vote
7 answers
Call by reference or Call by value
Could somebody please explain how this program is executed?
Here is the code whose output I just can't quite seem to get it:
class Box {
int size;
Box (int s) {
size = s;
}
}
public class Laser {
…

user2679090
- 13
- 3
0
votes
0 answers
what's the difference between call by value and call by rvalue reference in vector.push_back(const & T val) before c++11
Since rvalue references were not supported before C++11, there were no move constructors. The const T& arguments makes it use the copy constructor even for temporaries, which is the same as calling the copy constructor via a by-value argument?…

hhu_clj
- 1
0
votes
2 answers
Value of data change inside the heap memory?
So, I am trying to figure out how the value inside data changes accordingly. I have written comments to what i have understood. can anyone please explain how values stored in heap and stack memory for this problem.
public class CBV
{
static int…

Koushik Andhavarapu
- 31
- 3
0
votes
1 answer
call by reference failure
I have a task that requires handling a 4X4 matrix that is defined by typedef.
the task is to create a calculator for declared matrixes in main and interpret the commands from the user that passed as simple words. the problem is that I trying to pass…

Niv Turk
- 3
- 2
0
votes
2 answers
Python change list item
I am wondering why when changing values to a list by calling a function, there is such a difference in the following two scenarios (assign new value to list v.s. to list[:]). I guess it has something to do with…

Zhuang Paulus
- 81
- 8
0
votes
1 answer
the inplace parameter in pandas how it works?
in pandas the inplace parameter make modification on the reference but I know in python data are sent by value not by reference i want to know how this is implemented or how this work

Mahmoud Noor
- 186
- 12
0
votes
0 answers
PHP 8 call by reference unpurposly?
I am a bit confused about this scenario here.
Working with PHP 8.0.10.
In a class a have a member and getter method
/**
* @ORM\Column(type="datetime")
*/
private $gStart;
public function getStart(): ?\DateTimeInterface
{
return…

user3440145
- 793
- 10
- 34
0
votes
0 answers
Python Bytecode + LOAD_NAME by value or by name?
I'm a french CS teacher in highschool. We are investigating the execution of Bytecode on the Python Virtual Machine. We ended up with a naïve question : after a LOAD_NAME 0 (command at adress 8 of the bytecode) is executed, what's on Top of the…

smed
- 148
- 1
- 10
0
votes
1 answer
difference between passing parameters in function using call by value and call by reference
What is the return value of f(p, p), if the value of p is initialised to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value.
int f(int& x, int c)
{
c = c — 1;
if (c = = 0)
…