Is the Main module the only module where a relative path is not required?

Just noticed something which I’m slightly confused by and looks a bit inconsistent.

If I write a file main.jl containing the following code

include("ExampleModule.jl`)

ExampleModule.exampleFunction()

why does this work?

It just occurred to me that elsewhere I would be required to write

Main.ExampleModule.exampleFunction()

or

.ExampleModule.exampleFunction()

What is the reason for this difference?

I may not have provided enough information to go off here. Let me know if this is the case and I will try to add to this.

I also didn’t drink my morning coffee yet. It’s possible this is a dumb question and I just haven’t realize it yet.

I think the REPL has the concept of an “active module” (Main by default, but this can be changed). That’s probably what accounts for the difference in behavior.

1 Like