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
0
votes
2 answers
Haskell Semantics call by name / value
I am new with Haskell, I have a question
h x = x : (h x)
g xs = [head xs, head xs - 1]
What is the result of running g(h 2) assuming the semantics is call-by-name and call-by-value ?

Menma Yuna
- 35
- 1
0
votes
2 answers
Java vs C++ (Call-By-Reference?)
I am not sure if this topic is about Call-By-Reference but I have a question about these 2 snippets:
Java
public static int calculateWinner(int[][] game){
game[0][0] = 5;
.
.
.
}
public static void main(String[] args) {
int[][]…

Haidepzai
- 764
- 1
- 9
- 22
0
votes
2 answers
Is there a way to guarantee that a real referenced object has no side effect for a caller function?
I'm a student who recently learns JAVA.
I approaches this language based on my C++ experience.
So It took me almost four days to understand the gap between c++ and java in terms of the call-by-value or reference.
Java is call-by-value because a…

user7024
- 311
- 2
- 10
0
votes
2 answers
Tail recursion and call by name / value
Learning Scala and functional programming in general. In the following tail-recursive factorial implementation:
def factorialTailRec(n: Int) : Int = {
@tailrec
def factorialRec(n: Int, f: => Int): Int = {
if (n == 0) f else…

Jason
- 2,495
- 4
- 26
- 37
0
votes
2 answers
Confused between call by ref and call by value in my code
Just started C this year in my uni and I'm confused whether my function call is by reference or value.
I created an empty array in main called freq_array and this is passed as an argument when the function frequency is called. So since after the…

QQQ
- 97
- 7
0
votes
4 answers
How can I understand the concept of pointers (*) and address-of (&) operators?
I am trying to understand the significance of these two operators, so I wrote this code just for that purpose.
#include
#include
int main()
{
char *mnemonic, *operands;
mnemonic = "add";
operands = "five to two";
…

Tina
- 179
- 1
- 3
- 13
0
votes
2 answers
How to pass arguments to function pointers
I'm working with function pointers in c because I need a callback mechanism for my custom API library.
Summarizing with a simple example:
*userfunction*(SY_msg msg)
{
/* do something */
};
The size of SY_msg is 1024 bytes.
1024 bytes are…
user3859646
0
votes
1 answer
Python: Passing a list as parameter so the actual list is sorted
I wrote a merge sort function and thought I was done.. but in the assignment it says that the function is supposed to sort the actual list instead of creating a copy (so call by value instead of reference I think?). Right now, it doesn't work…

Dennis
- 57
- 1
- 2
- 10
0
votes
2 answers
C++, program outputs invalid input but continues through loop
I am trying to write a program which calculates the cost of a call based on the time the call was made, the day of the week and length of call. It has to be all call-by-value functions and output a option to repeat the program.
My problem is when I…

Sam S.
- 19
- 4
0
votes
2 answers
Difference between the execution of a+=2 and a=a+2?
void increment(int a)
{
a+=2
}
void assign(int a)
{
a=a+2
}
In which of the parameter passing technique a call to increment(b) will have a different effect
from a call to assign(b)
1) call by value
2) call by value result
3) call by…

Amrata Ramchandani
- 83
- 1
- 9
0
votes
1 answer
PHP call by value returning less value to the main function
I have a weird issue, i wrote an recursive function to get more results from facebook. In the called function(recursive) i am returning the values to the main function. In the called function when i print the returned value it displays the exact…

RAUSHAN KUMAR
- 5,846
- 4
- 34
- 70
0
votes
1 answer
Keep Reversing the no. & adding it to the original no. until there is a Palindrome Number
It's not "Find the Palindrome of a Number" ! it's a bit twisted than that:
Step 1: Reverse the digits of a original number.
Step 2: Add the reversed number.
Step 3: If the new number is a palindrome number then print the output.
The limit is 15…

user58736
- 9
- 8
0
votes
0 answers
Understanding call-by-value in Python
Here is my example:
def test(word):
print(id(word))
word.append('noun')
word = ['something','new']
print(id(word))
And it works as expected:
w = []
test(w)
produces:
140570192034056
140570192034568
and
…

user1700890
- 7,144
- 18
- 87
- 183
0
votes
0 answers
What will be output of following code in different scoping and calling convention?
int a = 2;
void f(int b){
b = b*a;
a = a-b;
}
void main(){
int a = 10;
f(a);
print a;
}
a) Call-By-Value and Lexical Scoping
b) Call-By-Value and Dynamic Scoping
c) Call-By-Reference and Lexical Scoping
d) Call-By-Reference and Dynamic Scoping
My…

lifeisshubh
- 513
- 1
- 5
- 27
0
votes
1 answer
Trying to create a login page using tkinter in python, doesn't seem to work
The below code is what i am working on, I am trying to create a login page and validate username and password. Ideally loginValidate function should be invoked when i click on the submit button, but it is invoked even before i do so. Also the…

YogeshReddy
- 23
- 1
- 6