Proposed syntax for _root_

I think absolute imports should be encouraged with lightweight syntax while relative imports should come with a syntax tax. Absolute imports are inherently easier to reason about.

One proposal: make fully qualified imports the default and impose a . prefix for relative imports

import fully.qualified._ // becomes import _root_.fully.qualified
import .relative.name // becomes import relative.name

this would extend to local imports and imports on the empty package

def foo(a: Foo) = {
  import .a._
}

import .Bar._
object Bar

Nothing should change how reference resolve outside of imports.

4 Likes