Questions tagged [callbyname]
86 questions
2
votes
1 answer
Call by Name/Call by Value
I'm trying to understand this block of code here:
#include
using namespace std;
#define mymult(a, b) a*b
inline int mymult1(int a, int b) {return a*b;}
int main() {
cout << "mymult(2+2, 3+3) = " << mymult(2+2, 3+3) << "\n";
cout <<…

Tabrock
- 1,120
- 1
- 20
- 37
2
votes
4 answers
In Scala, is a function that takes call by name parameter different from a function that takes another function as parameter?
Say, first, I have this function:
def number5()={
println("number 5 starting")
println("number 5 exiting")
5
}
And then:
def giveMeCallByNameParameter(f: =>Int)={
println("starting")
f
println("exiting")
}
When…

Cui Pengfei 崔鹏飞
- 8,017
- 6
- 46
- 87
2
votes
4 answers
Does C# support call-by-result?
I'm aware of 3 parameter evaluation types in C#:
default, which is by-value
ref, which is by-ref
out, which is by-ref but considered initially uninitialized and mandatory to assign
My professor stated that C# also supports by-result, which he…

mafu
- 31,798
- 42
- 154
- 247
2
votes
2 answers
Scala call-by-name constructor parameter in implicit class
The following code does not compile. Desired is to have a call-by-name constructor parameter in an implicit class as illustrated here,
def f(n: Int) = (1 to n) product
implicit class RichElapsed[A](val f: => A) extends AnyVal {
def elapsed():…

elm
- 20,117
- 14
- 67
- 113
2
votes
1 answer
Whats the wrong with passing me as parameter in CallbyName funktion under vb6?
I want to pass the sourceform, from which I use the CallByName-function. Somehow, it doesn't work in way I post it down there.
Private Sub Command1_Click()
'CallByName Form1, "TestFkt", VbMethod, Nothing, Command1 '<--- works
CallByName…

thomas G
- 123
- 4
2
votes
1 answer
parameter list ("*") with lazy "by-name" parameters?
I can:
scala> def foo( f: => String) = println(f)
foo: (f: => String)Unit
and I can:
scala> def foo( f: String*) = f.map(println)
foo: (f: String*)Seq[Unit]
but I can't:
scala> def foo( f: =>String* ) = f.map(println)
:1: error: ')'…

nairbv
- 4,045
- 1
- 24
- 26
2
votes
2 answers
Accessing subclass or subproperty using CallByName
I can access class' subvalues using CallByName (In other words, I can get Class.SubValue with it).
But I get error when I want to get Class.SUBCLASS.SubValue using CallByName.
Is it possible to do it using CallByName (or by using smtg else)?
Here's…

Jet
- 528
- 6
- 17
2
votes
2 answers
Does "Call by name" slow down Haskell?
I assume it doesn't.
My reason is that Haskell is pure functional programming (without I/O Monad), they could have made every "call by name" use the same evaluated value if the "name"s are the same.
I don't know anything about the implementation…

pochen
- 873
- 12
- 22
1
vote
1 answer
Iterate Over Static Array of Objects
I want to iterate over several ComboBox objects in the same Worksheet sht:
Dim obj As ComboBox
Dim sht as Worksheet
...
For Each obj In Array(sht.ComboBox1, sht.ComboBox2)
Next obj
Runtime error 424: object required (raised at For Each ...)
I…

ascripter
- 5,665
- 12
- 45
- 68
1
vote
2 answers
How do I use CallByName or Invoke with Async/Await
CallByName and Invoke are not async functions so I can't call them asynchronously using the obvious syntax like:
rv = await CallByName(objScripts, txtScript.Text, CallType.Method)
Apparently I am the only one to ever need this so no answers on the…

Brad Mathews
- 1,567
- 2
- 23
- 45
1
vote
1 answer
Scalamock: Mocking call by-name function with arguments
In following code snippet, I need to ensure that BinaryConverter#intToStr is invoked.
import org.scalamock.scalatest.MockFactory
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class Foo {
def foo(x: Int)(b:…

rojanu
- 1,592
- 5
- 20
- 34
1
vote
2 answers
CallByName with multiple levels of properties
I want to use CallByName in VBA to read a specific data from such webpages. Those webpages have different html structures. In my case, there is a element that I need to refer 2 or 3 parent nodes and get an element with or tags. See the…

AliM67
- 123
- 12
1
vote
1 answer
Call-by-need and call-by-name reduction relation semantics
While trying to summarize my knowledge about lambda calculus, I understood that I'm quite familiar with call-by-value but I've never seen сall-by-need reduction semantics. I know the definition, but it would be great to see precise meaning.
This is…

vonaka
- 913
- 1
- 11
- 23
1
vote
2 answers
Conversion to tuple with by-name parameter
I would like to create a function with the following signature:
def myFunction[T](functionWithName: (String, => T)): T
so that I can call it, e.g., like this: val x = myFunction("abc" -> 4 * 3). Tuple doesn't accept by-name parameter, however, so…

Mifeet
- 12,949
- 5
- 60
- 108
1
vote
1 answer
Call by name vs normal order
I know this topic has been discussed several times, but there is something still unclear to me.
I've read this question applicative-order/call-by-value and normal-order/call-by-name differences and there is something I would to clarify once and for…

Usr
- 2,628
- 10
- 51
- 91