Is scala import recursive?

import, scala

Solution

No, Scala import is not recursive.

Packages are there to keep the namespace in the current scope clean. Importing all subpackages by default would go against that.

On the other hand, imports are relative, so you can do this:

import mypack._
import box.writer
import box.reader
import box.parser.stringparser

Some people dislike this style, as it is somewhat error-prone. I dislike it because there's no clear distinction between absolute and relative imports. Still, it helps sometimes.

Problem

With ``` import mypack._ ``` do I still need to ``` import mypack.box.writer import mypack.box.reader ``` and ``` import mypack.box.parser.stringparser ``` ? And what's the proper keyword to search/google? "Recursive" gives me overwhelming "tail recursion" results.

Original source