Hi,
I don't understand the way of importing/using modules, or including files.
I've look at documentation (FAQ and modules) and into this list for old 
subjects, and tested all solutions I found.

with julia version 0.4.3 on gentoo

directory structure looks like:

package.jl (directory)
  |_ src
  |  |_ fileA.jl
  |  |_ fileB.jl
  |  |_ fileC.jl
  |  |_ fileD.jl
  |  |_ package.jl
  |_ test
     |_ testA.jl

The* first issue* I had was with "using" in tests, for example I've tried:

push!(LOAD_PATH, string(dirname(@__FILE__), "/..src")) # just to try - 
ModuleA is in fileA.jl in ../src
using ModuleA
# alternativelly:
# using ModuleA.TypeA1 or using ModuleA: TypeA1...
facts("Test ModuleA") do
  context("create") do
     type_a1 = ModuleA.TypeA1()
  end
end


I've tested launching this test with :
JULIA_LOAD_PATH=./src/ LOAD_PATH=./src julia --color=yes test/testA.jl

(no differences with import too)

The error message is:
ERROR: LoadError: ArgumentError: ModuleA not found in path

Instead of import/using (but that's not what I wanted), It's OK if I use :
include("../src/fileA.jl")



The *second issue* is when I wanted to define modules in package.jl this 
way:

module Package
  module ModA
    include("fileA.jl")
    include("fileB.jl")
  end
  module ModC
    include("fileC.jl")
  end
end

And have for example a fileD.jl included in fileA.jl and fileB.jl (or 
fileC.jl) with and immutable type. (I've included fileD.jl because I 
couldn't use "using" but I would prefer "using")
I have an error ERROR: LoadError: LoadError: LoadError: LoadError: 
LoadError: invalid redefinition of constant ImmutableType

So as I can't use "using" to avoid the reloading what can I do? 
what I've not understood about julia import/using and include ?

NOTE:
some things I've tried: fileD.jl with a module ModuleD and "using" with and 
without  __precompile__
setting LOAD_PATH and JULIA_LOAD_PATH globally with bashrc or passing it to 
shell
...

Reply via email to