Updated Proposal: Revisiting Implicits

Here my summary - mainly a selection of what others have already said:

positive:

  • anonymous parameters; this is very useful
  • multiple given lists are good
  • requirement to qualify given parameter when explicitly passed is very good
  • import *.given is good
  • extension methods, calling like a function, e.g. max(arg), very good, I always wished we had that

negative:

  • unclear when instantiation happens, e.g. what soronpo said: given global: ExecutionContext = ... (because val, lazy val and def are gone)
  • what lihaoyi said, there is a conflict/ambiguity with refinement types in given intOrd: Ord[Int] { def compare(x: Int, y: Int) = ??? }

open:

  • there’s an open question by katrix whether we get less contrived way to make sure there are priorities between implicits

I have another question for the extension methods ‘function call syntax’; what if there are arguments, like

def (i: Int) absDif (j: Int): Int = math.abs(i - j)

I know I can invoke as 33 absDif 44, but how would the function call syntax work here – is it absDif(33, 44) or absDif(33)(44) or simply not defined? From my use cases, putting them into one parameter list would probably be the most useful, e.g. atan(dy, dx), randomRange(lo, hi) etc.

4 Likes