Implicitly loaded modules in the future?

In brief: the current approach to organising several files worth of code is something like:

# master.jl
include("utils.jl")
include("A.jl")
include("B.jl")

# utils.jl
common = 1

# A.jl
foo = common + 2

# B.jl
bar = common + 3

in which A.jl and B.jl implicitly depend upon utils.jl.

Being implicit in this way introduces various issues. For example it’s hard to tell, whilst reading A.jl, what common is, where it came from, what it does. (Much of this discussion has focussed around the task of reading or maintaining existing code.)

The hope is to switch this out for a syntax looking something like:

# master.jl
import "A.jl": foo
import "B.jl": bar

# utils.jl
common = 1

# A.jl
import "utils.jl": common
foo = common + 2

# B.jl
import "utils.jl": common
bar = common + 3

to make the dependency structure between files explicit. The main motivation being to try and address the drawbacks previously stated.

27 Likes