Questions tagged [callbyname]
83 questions
0
votes
2 answers
Using callbyname to check list.contains(x)
I've been trying to use callbyname to write a generic function which checks if the target list (targetListName) contains a certain item before adding it to the list. Unfortunately, I can't seem to figure out how to use .contains with callbyname. …
PostalElf
- 15
- 6
0
votes
0 answers
Call-by-name evaluation and foreach loop
I faced this problem for the first time and I can't figure it out.
Let's say we have an array and a foreach loop.
Something like this:
var v = array(10,20,50);
var i = 0
write(foo(v, v[i++]));
function foo(ref int[] v, name int y){
foreach(int j…
joeguarino
- 1
- 1
- 2
0
votes
3 answers
Call by Name with dynamic scoping
I am stuck at the following problem on static/dynamic scoping:
The following program fragment is written in a programming language that allows global
variables and does not allow nested declarations of functions.
global int i = 100, j = 5;
void…
Pale Blue Dot
- 5,611
- 10
- 66
- 100
0
votes
2 answers
Call by value, reference and name
Possible Duplicate:
Pass by Reference / Value in C++
I was wondering what the difference is between a call by value/reference/name. And why would it be beneficial to use one over another?
Chen Li
- 151
- 1
- 2
- 8
0
votes
1 answer
Mismatch between call-by-name parameter and function type
In the following scenario, by-name parameters cause conflict with functions.
Given some serialization infrastructure:
trait Tx {
def readSource[A](implicit ser: Serializer[A]) : Source[A] =
new Source[A] {
def get(implicit tx:…
0__
- 64,257
- 16
- 158
- 253
-1
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
- 43
- 1
-1
votes
1 answer
Visual Basic: CallByName with multiple "Levels"
I've been working on this for quite a bit now but I still cannot get my code going.
I have a class called Contact which has a read-only property Address. The Address class has properties like Street and City. Now I want to assign a contact's street…
Jannes
- 19
- 5
-3
votes
1 answer
What is the result and example of invoking this function using "Call by name" in java or c++?
I just took a quiz for my programming languages class and came across this question:
Assuming call by name, what are the results of following code:
public class MyClass {
static int i = 1;
static float f(int x, int i){
int s = 0;
…
Remixt
- 641
- 4
- 23