I found out that by-name parameters and functions are very similar. What is the advantage the first ones against the second ones?
object ws1 {
  def myByFunc(f: () => Int) = f()                //> myByFunc: (f: () => Int)Int
  def myByName(f: => Int) = f                     //> myByName: (f: => Int)Int
  def testFunc(a: Int) = a * a                    //> testFunc: (a: Int)Int
  myByFunc(() => testFunc(123))                   //> res0: Int = 15129
  myByName(testFunc(123))                         //> res1: Int = 15129
}
UPDATE: Regarding the question of how many times each of them executes:
object ws1 {
  def myByFunc(f: () => Int) = {
    println("111111111 myByFunc")
    f()
  }                                               //> myByFunc: (f: () => Int)Int
  def myByName(f: => Int) = {
    println("22222222 myByName")
    f
  }                                               //> myByName: (f: => Int)Int
  def testFunc(a: Int) = a * a                    //> testFunc: (a: Int)Int
  myByFunc(() => testFunc(123))                   //> 111111111 myByFunc
                                                  //| res0: Int = 15129
  myByName(testFunc(123))                         //> 22222222 myByName
                                                  //| res1: Int = 15129
}
For some reason they both execute 1 time. Why?
UPDATE2: Neither of them is evaluated:
object ws1 {
  def myByFunc(f: () => Int) = {
    println("111111111 myByFunc")
  }                                               //> myByFunc: (f: () => Int)Unit
  def myByName(f: => Int) = {
    println("22222222 myByName")
  }                                               //> myByName: (f: => Int)Unit
  def testFunc(a: Int) = {
    println("hello from test func")
    123456
  }                                               //> testFunc: (a: Int)Int
  myByFunc(() => testFunc(123))                   //> 111111111 myByFunc
  myByName(testFunc(123))                         //> 22222222 myByName
}
 
     
    