Personally, I am already using this proposal along with the other contextual abstractions in a 5500+ line codebase. I really like the given
keyword, I think it makes sense to say it’s some constraint on the current values in scope.
My only complaint is that, having confirmed with a non-scala programmer, that given that the inferrable parameters in def fancy given A, B, C = "Fancy!"
do not really look like a parameter list, (which is the intent), why should they be applied as a whole list if you only want to update a single one?
for example, using only new features in this proposal:
trait A
trait B
trait C
def fancy given A, B, C = "Fancy!"
implicit object A_ extends A
implicit object B_ extends B
implicit object C_ extends C
println(fancy)
val newFancy = fancy given (implicitly[A], implicitly[B], new C {})
Now I must summon all the other values to change a single implied argument. However, I don’t think it’s possible to really prove which implied parameter list is the correct one if you allow partial application and generate the other arguments.
This causes me never to use given
at the use site and instead update the implied scope in a previous statement in a block before calling, or otherwise restrict myself to only single argument implied parameter lists.