callbyname Questions
4
Solved
Scenario:
I want to implement an infinite list:
abstract class MyList[+T]
case object MyNil extends MyList[Nothing]
case class MyNode[T](h:T,t: => MyList[T]) extends MyList[T]
//error: `val' p...
Delmardelmer asked 5/11, 2014 at 4:10
2
Let's assume we have the following code in a language that looks a lot like C.
int A[2];
A[0]=4;
A[1]=7;
void f(int x, int y) {
x++; A[1]++; y++;
printf(x, y, A[0], A[1]);
}
void main()...
Scribe asked 22/6, 2019 at 15:49
2
I am currently using CallByName to dynamically call methods. There are several methods which I pick up daily from a table in server along with the arguments. For this reason, I send an array of the...
Slaughter asked 25/5, 2016 at 8:59
2
Solved
As I understood call-by-name parameters of a method, the corresponding argument expression will not be evaluated when passing it to the method, but only when (and if) the value of the parameter is ...
Node asked 11/11, 2015 at 17:42
1
Solved
Let's see the code below:
import scala.language.implicitConversions
class Foo
implicit def int2Foo(a: => Int): Foo = new Foo
def bar(foo: Foo) = {}
def bar(foo: Boolean) = {}
bar {
println("He...
Case asked 7/7, 2015 at 14:35
5
Solved
Can anyone tell me how I can implement Call By Name in C#?
Convent asked 25/10, 2010 at 21:57
2
Solved
def getStr(): String = {
println("getStr is running")
"str"
}
def lazyHello(para: => String) = {
println("lazy hello is runing")
println(para)
}
def notLazyHello(para: String) = {
println...
Tnt asked 19/11, 2013 at 12:58
1
Solved
I'd like to be able to mock a return value of getOrElse method so that it returns what is passed as orElse call-by-name argument with ScalaMock
trait ToBeMocked {
def getOrElse(arg: Int)(orElse: ...
Hann asked 18/8, 2013 at 1:18
3
Solved
In my principles of programming class we are talking about different calling methods. Some we discussed were:
call by value
call by reference
call by value/result
and call by name
I can't find ...
Pollen asked 25/7, 2010 at 21:43
1
Solved
Here are two statements that seem to be generally accepted, but that I can't really get over:
1) Scala's by-name params gracefully replace the ever-so-annoying log4j usage pattern:
if (l.isDebu...
Iasis asked 2/11, 2012 at 16:21
2
I've been looking at the various scala logging libraries lately, and the vast majority of them implement their logging functions as
def debug(s: => String)
So that if you have debug logging t...
Khorma asked 31/7, 2012 at 16:37
1
Solved
In Perl, you are able to call a function by reference (or name) like so:
my $functionName = 'someFunction';
&$functionName();
#someFunction defined here:
sub someFunction { print "Hello ...
Adown asked 20/6, 2012 at 16:44
1
© 2022 - 2024 — McMap. All rights reserved.