Search code examples
scalaimplicits

Is there any style guidelines about using implicit parameter with default value in scala?


Is it fine to use such solutions like here:

def convert[T](x: T)(implicit format = Default) = ...

It allows you to not specify implicits if you don't need to. But many libraries (at least Lift Json and Scala Concurrent) avoid such kind of default implicit values and push user to always specify an implicit. Is there any recommendations about it for library designers?


Solution

  • Retronym said in passing:

    https://groups.google.com/d/msg/scala-user/6MudBXELxVQ/ul67d5Rh4b4J

    Arguably it is in poor style to define implicit params with defaults

    Compare:

    implicit parameter VS default parameter value

    and here's a good one:

    https://stackoverflow.com/a/20016152/1296806