Proposed syntax for _root_

import package.foo.bar.baz means you’re importing from the package foo the path bar.baz, and not some random foo that happens to be in scope.

Given import package.foo.blah, any blah after the initial import package.foo behaves just like any other import. If you’ve ever imported something in Scala, this behaves the same way. package is just an alias for _root_ that won’t get shadowed and looks less ugly (?).

Though I see value on using an absolute import over an expression – after all, if you use an absolute import inside blocks and entities’ bodies, you better make it explicit so that it’s clear that it doesn’t reuse a local symbol.

I don’t really understand what this means. If you use package.foo.Bar.doSomething(...), the package keyword makes it abundantly clear you’re not using a local symbol. In fact, it is clearer than having some import 1000 lines up at the top of the file and then trying to figure out which Bar you have in scope to call doSomething with.

1 Like