Page tree
Skip to end of metadata
Go to start of metadata

Rational

Scala is a very powerful language. It has a lot of "magic" features that allow you to design extremely nice APIs.
At the same time, some of those feature can make the code harder to reason about.
Examples are
 - implicit parameters
 - implicit type parameters
 - implicit conversions
 - lazy parameters
In particular, code reviews on GitHub become tricky, as code does not necessarily look like what it does.
As an example: Without IDE support, it is hard to see the difference between a lazy parameter and an eager parameter. The difference may be crucial for error handling (when can an exception be thrown).

Guidelines 

In projects that define APIs built on Scala, we use all the language magic that is available to make the APIs as nice as possible.
In other projects (runtime projects), we refrain from the use of magic features, to make code easier to reason about and error handling more explicit.
These projects should refrain from using the following features (so far as possible without making the code awkward):
  • lazy parameters
  • implicit type parameters
  • implicit parameters

 

Implicit conversions make sense in many cases (such as to bridge between the Java and Scala collection frameworks).

Surprising implicit conversions (that alter behavior) should be replaced by explicit calls to the converting function. This is up to every committers reasonable judgement.

  • No labels