Implicitly loaded modules in the future?

Here’s another example that demonstrates the vacuity of a system like FromFile.jl. Suppose we start with this:

# A.jl
function foo end

# B.jl
@from "A.jl" import foo
bar(::Int) = 1
foo(x) = bar(x) 

Ok, great, now we know that file B.jl only depends on file A.jl. But suppose we add another file like this:

# C.jl
@from "B.jl" import bar
bar(::Float64) = 2 

The new package with the addition of the C.jl file will load and run just fine. But now the behavior of foo is different, because we’ve overloaded bar. File B.jl asserts that its contents, including foo, only depend on file A.jl, but that is wrong! In fact, the behavior of foo now also depends on file C.jl, even though there is no @from "C.jl" statement at the top of B.jl.

To summarize:

  • The @from dependencies listed at the top of a file are incomplete.
  • Modules do not isolate dependencies in a language where every function has a global method table.
12 Likes