miniblog.

← Back to all posts
62
I'm debating whether `from foo import *` is a bad feature for my toy programming language. Forcing `import foo as f` and later `f::bar()` is so much more amenable to local static analysis. You also don't get issues with name clashes. It's certainly convenient though.

2 Comments

@wilfredh Allowing just `import foo` and `import { bar } from foo` (or whatever variations you choose on those) is “good enough” in my experience. `foo:bar()` is fine, `bar()` is fine, and supporting `Ident as Ident` for either solves any namespace collisions. I always end up preferring namespace-style imports *anyway*. The only real exception I can think of is traits from crate-supplied extra preludes in Rust, but that’s because name resolution on trait-supplied methods is kind of weird!