8

One of the recent commits to Scala master removes restriction on combining context/view bounds with implicit parameters. That's a great improvement that reduces amount of boilerplate, but what was the reason of making that restriction before, and what consequences can we expect now?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Vasil Remeniuk
  • 20,519
  • 6
  • 71
  • 81

1 Answers1

5

Context and view bounds add implicit parameters. So if you write:

def f[T : Manifest](l: List[T])(implicit ord: Ordering[T]) 

There are, in fact, two implicit parameters being passed instead of one. Allowing this kind of syntax will certainly result in some confusion down the road. As implicit parameter usage starts to get more widespread, because of type classes, being able to do something like the above is helpful.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
  • "Context and view bounds add implicit parameters" >> sure, I know that. I was rather interested, if it's caused with any technical difficulty. – Vasil Remeniuk Jul 27 '11 at 05:19
  • IMO, not being able to use the bounds along with implicit parameters might also be very confusing for a newbie :) – Vasil Remeniuk Jul 27 '11 at 05:22
  • @Vasil I'm not saying it is a bad decision, just that it adds a certain degree of... confusion. It would be illegal to call the above function like `f(List(1 -> 2, 2 -> 1))(Ordering by (_.swap))`, even though it _seems_ to have all parameter lists filled correctly. – Daniel C. Sobral Jul 27 '11 at 15:18