private inline fun findFixpoint(f: (Double) -> Double): Double { var x = 1.0 while (true) { val y = f(x) if (x == y) return y x = y } }
val cosfix1 = findFixpoint { Math.cos(it) }
The first call compiles down to what you’d expect (tight code), the second performs invocations of the function via helper classes and so on. But my understanding of the Kotlin syntax is that both forms mean the same thing, so why do they compile differently? Is this just a lacking bit of smartness in the compiler or is there some deeper reason?