Suggestion: optional arg names in function literals


If we pass functions that have one parameter, we can use implicit it variable.

for example

fun test(f:(x:String)->Unit){
  f(“invoked here”)

test{print(it)};//using implicit it variable

but if we have two or more params in the passing function - we have to define them explicitly:

fun processImage(f : (r : Int, g : Int, b : Int)->Unit) {
  f(1, 2, 3);

processImage{r, g, b -> print(“rgb value is: {a} {b} ${c}”) };   
this is a boilerplate code

So my suggestion is the ability to call it without explicitly defining arg names, that are already defined in signature f:(r:Int,g:Int,b:Int)->Unit:
processImage{print(“rgb value is: {r} {g} ${b}”)};

It’s a good syntactic sugar for DSLs

Is it possible to implement?
I know - there is a way to make a tuple with named fields #(r,g,b) and to use it as it.r , it.g, it.b, but it’s not so handy.


Thanks for your suggestion. We'll need to think about it.