Revisiting modules, take 3

However, Python also doesn't allow you to use things from another "crate" at all without importing, right? Paths inside the module are relative, and there is no "be absolute" modifier. That would be problematic in Rust at least for error messages, which may have to mention types that have not been imported but only come up due to inference.

Ah, I never thought about this. I didn't even notice that relative imports work "differently" in __init__ vs. other files. Neat!


So do you mean to rule out code like this, or to somehow make it less surprising that this stops working when moved into a submodule?

mod foo {
  fn bar() {}
}
use foo::bar;

fn main() {
  bar();
}

At this point we are talking about use mystuff vs. use ::mystuff, so the question is whether it is worth to have two additional characters at almost all crate-local uses to remind us that these are absolute. Or, phrased the other way around, is some weaker form of path confusion a price worth paying for saving two characters per crate-local use?


This actually would be a special case -- the [std]:: prefix roots the path, but so far I have not seen as [std] as being an item on its own.