The order of named parameters passed affects behavior in an unexpected way.
class Family(val mom: String, val dad: String, val kids:String*)
// this works
val f1 = new Family(mom="Mom", dad="Dad")
// this does not
val f2 = new Family(dad="Dad", mom="Mom")
In summary, parameters passed in same order as class definition work fine. Parameters passed in a different order fail with complaint:
error: when using named arguments, the vararg parameter has to be specified exactly once
Only causes problem when also declaring a variable argument list.
-------
while the error messages seem to be correct, the current behavior has led to complaints that the rules are too strict, and I certainly agree with that point.
I remember that there have been some efforts to make the compiler behaving more intelligently, but is has been shown that coming up with a solution which is
a) easy to specify, complete and unambiguous AND
b) easy to implement and test AND
c) easy to understand AND
d) easy to use
is surprisingly hard.
As far as I know, that's the reason why the spec/compiler is pretty conservative and rejects code which looks straightforward to the human eye.
I think I remember that there were some commits regarding named parameters a few months ago. Did you try your code examples with Scala 2.10? Maybe there are some improvements already available?
Bye,
Simon
I posted the following as a bug and it was rejected as "expected behavior".
Here's the issue. This smacks of leaky implementation details.