The convention to make things private is to not export them. When "using" a module, which is the normal way, those non-exported modules are not visible in the current scope. They are still accessible when using the fully qualified path.
Am Dienstag, 10. Juni 2014 21:39:56 UTC+2 schrieb Davide Lasagna: > > Thanks Patrick. > > Does this mean that there is no way to make things private? I thought > that only explicitly exported symbols where accessible. > > Anyway then, what is the common approach in Julia to mark things as > private? Python use single and double leading underscores, but haven't seen > too much _s in JUlia code. > > Davide > > On Monday, June 9, 2014 10:32:23 PM UTC+1, Patrick O'Leary wrote: >> >> Use the "using" keyword instead of the "import" keyword, in conjunction >> with your (correct) intuition about "export". >> >> module MyModule >> >> include("file.jl") >> export foo >> >> end >> >> ... >> >> using MyModule >> foo() >> MyModule.bar() >> >> On Monday, June 9, 2014 4:21:16 PM UTC-5, Davide Lasagna wrote: >>> >>> Hi all, >>> >>> I have a question about modules and I am probably missing something. >>> >>> Say that in file.jl I define functions foo and bar. I then create a >>> file MyModule.jl where I include file.jl as: >>> >>> module MyModule >>> >>> include("file.jl") >>> >>> end >>> >>> >>> At this point, in the REPL, doing import MyModule will give me access >>> to both foo and bar. Say, however, that I only want foo to be visible >>> from the outside, while I want bar to remain private, because it is >>> some accessory function used in foo. >>> >>> What is the preferred way to achieve this? I thought that after >>> include("file.jl") >>> I should have added an export foo to make it accessible to the outside, >>> but the include function is making everything in file.jl visible. >>> >>> Thanks, >>> >>> Davide >>> >>>