Functional Declaration & Higher Order Functional Types

With 1.0 release, I finally started looking at Kotlin docs [1]. For higher order functional support, the syntax is:

fun <T> lock(lock: Lock, body: () -> T): T { lock.lock() try { return body() } finally { lock.unlock() } }

Is there any technical reasons why normal function declarations are not using ‘->’ as a return operator ?.

fun hello(name: String) -> String { println(name) return "Hello", name }
Swift [2], Rust & others are using it.

It will just make the experience uniform with consistent Functional Types.


Well, we could go either with “function return types are like variable and parameter types” or “function returns types are like in function types”. We went for the first, and liking the result (it’s pure taste, after all). BTW, initially we tried using “:” for function types as well, but it turned out to be hard to read.