Have the compiler generate thunks to populate default function parameters

Should test use the default value for the second param? Will second forEach lead to the compilation error? Can we apply several parameters this way?

func test(first: Int = 1, second: Int = 10) -> Int {
    return 10 
}

func anotherTest(first: String = "1", second: Int) -> Int {
    return 10 
}

func multiApply(first: Int, second: Int, third: Int = 10) -> Int {
    return first * second * third
}

[1, 2, 3].forEach(test)
[1, 2, 3].forEach(anotherTest)
[(1, 2), (3, 3)].map(multiApply)

In your case(print) there is another issue: variadic parameters. Should compiler just send single value as the variadic parameter?

I am trying to introduce simple idea "this pitch is great, I am suffering from the same issue on daily basis, but we should develop univocal rules". So, for now, I have three questions:

  • How should this mechanism handle variadic parameters?
  • May "not aligned" arguments be skipped? (anotherTest example)
  • Can I pass several arguments to function this way(multiApply example)? If so, how "not aligned" and variadic parameter issues may be combined with multi arguments pass?

If rules will be strict(can't skip not aligned params, variadic params receive only one value), there will not be a "combinatoric number of such conversions" issue, I guess.

Btw, looking forward to partial apply in swift...