JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.74k stars 5.49k forks source link

2.0: just one import keyword #39235

Open StefanKarpinski opened 3 years ago

StefanKarpinski commented 3 years ago

I would very much like to have just one import keyword in Julia 2.0. I don't much care if it's import or using but since we talk about it as "importing" things, that may be more natural. With https://github.com/JuliaLang/julia/issues/39187 and some requirement for explicitly requesting extension of external generic functions, this would be possible.

current form new form comment
import Foo import Foo just imports Foo
import Foo: Foo, bar import Foo: bar in 2.0 import Foo: bar imports Foo also
import Foo: bar import Foo as _: bar use Foo as _ to discard that name
using Foo import Foo...
using Foo import Foo: ... longer version of the previous one
using Foo; using Foo: bar import Foo: bar, ... implicit and explicit imports on one line
using Foo as _ import Foo as _: ... use Foo as _ to discard that name

In 2.0 I think we should eliminate the distinction between the "soft binding" that using creates and the hard binding that import creates and just make all explicit bindings hard and all implicit bindings soft: if you asked for it by name, it's a hard binding, if you didn't, it's a soft binding. When someone wants to extend an implicitly imported generic function, they have to fully qualify it.

StefanKarpinski commented 2 years ago

We really want to go in the opposite direction: code loading should be more statically resolvable, not less.