Calling a module from a module in a different directory

#1

Hi,
just a question about calling a module from another module which is located in a different directory. For instance imagine I have a module mytypes.jl

module myTypes
export CROCO, krok1
export bite
abstract type CROCO end
struct krok1
   x :: Int64
end
function bite(x)
   return x*x
end
end

in folder /home/animals/modules/Reptiles
Now I have a second folder /home/animals/modules/Beasts
where I have a second mudule that has to use the myTypes module

module myFuncs
push!(LOAD_PATH,"/home/animals/modules/Reptiles");
using myTypes
function cayman(c::CROCO)
   return c.x
end
end

My problem is that, when trying to load myFuncs, it fails and complains because it can’t understand the CROCO variable, as if the module myTypes.jl has not been loaded -or maybe is a scoping problem (?)
Bottom line is: how can I make myFuncs module load and understand the data and function in myTypes modules, both being in different directories?
Best regards and thanks,
Ferran.

0 Likes

#2

Is mytypes vs myTypes just a typo here?

0 Likes

#3

Yes… Changed that in the original post.

0 Likes

#4

CROCO is not exported.

0 Likes

#5

Fixed, but that was not the problem :frowning: Of course it was a problem, but not the one I would like to solve…

0 Likes

#6

Should work as is.
By the way, the c.x in myFuncs will fail unless krok1<:CROCO

0 Likes

#7

Unfortunately, it doesn’t work. I mean to say, it does not work on my system -or I can’t make it work…

0 Likes

#8

Check that the path is correct and that the file is named myTypes.jl. It works in my case.

0 Likes