Using export keyword

question
#1

I am confused for the use of export in modules. In documentation I read that we use export to make functions available to user of that module . But I made a module(say A) ,which contains some functions and used export for some of those functions, in a file(f1.jl) and imported that file to another file(say f2.jl) using include(“f1.jl”) and there I was able to use all the functions by calling with the module A.functionName even if I didn’t use export to that particular function in module A.
Then what is the use of export??

0 Likes

#2

You should read the Modules section of the docs. using is for when you don’t want to preface A. to every call, and just write functionName directly.

iirc Julia doesn’t have a strict notion of private methods, which is important to the extensibility of methods and multiple dispatch.

4 Likes

#3

How to I use using in this case?? I tried it after using include and it threw an ArguementError: Package A not found in current path.

0 Likes

#4

Try using .A

https://docs.julialang.org/en/v1/manual/modules/#Relative-and-absolute-module-paths-1

2 Likes

#5

Thanks @greg_plowman it worked.:grinning:

0 Likes