Object paths across julia modules

Hey everyone!

I am currently developing a package and I have encountered a small problem. Imagine the following situation.

I have a module1 and module2, full of functions and a module3 full of objects/structs. This is all encapsuled in a package. Now, in module1 and module2 there are functions that return objects defined in module3!

When i want to use my package, and for the sake of simplicity, just want to compare the objects, i get an error that there is no conversion function found for objects of type module1.module3.Object to module2.module3.Object.

In my code i want to set an object i get from module1 to one that i got from module2! However, i would like to avoid running a loop! Is there a way to do this? Or a better module structure of defining the object in a global way, where it will always be just package_name.object?

Thank you for all the help in advance!

With kind regards,
Thomas

It sounds like you’ve used include to evaluate the file twice, which results in two separate and distinct copies of the inner module existing, which isn’t what you want. You’ll want to include the module a single time and then reference that single copy from both places.

2 Likes

Thanks so much! That was something I didn’t understand about how submodules communicate!