続「Scala スケーラブルプログラミング 第2版」で気づいたことなど

Scala 2.10.0 では、暗黙の型変換を何もせずに定義すると以下の warning が発生します。

warning: implicit conversion method intToRational should be enabled
by making the implicit value language.implicitConversions visible.
This can be achieved by adding the import clause 'import scala.language.implicitConversions'
or by setting the compiler option -language:implicitConversions.
See the Scala docs for value scala.language.implicitConversions for a discussion
why the feature should be explicitly enabled.

ということで該当する Scala docsを見てみると、なぜこのような Warning を発生させているかが書いてあります。

 Implicit conversions are known to cause many pitfalls if over-used.
And there is a tendency to over-use them because they look very powerful and their effects seem to be easy to understand. 
Also, in most situations using implicit parameters leads to a better design than implicit conversions. 

つまり、

  • 便利だけど多用すると罠が多い
  • 便利であるが故に多用しやすい
  • implicit parameter を使うほうがよいデザインになる場合が多い

ということのようです。