So if I have module A defining a struct, then with “using” import the struct to module B, and define a function on that struct. Then in module C “using” import both module A and B. When I try to run the function on the struct I get a method error. Is there any way to make the struct imported from A and methods from B apply to each other appropriately? MWE:
exampleimport.jl
module ExampleImport
mutable struct TestStruct
val::Int
end
export TestStruct
end
exampleimport2.jl
module ExampleImport2
include("exampleimport.jl")
using .ExampleImport
function teststructmod!(x::TestStruct)
x.val = 10
end
export teststructmod!
end
example.jl
include("exampleimport.jl")
include("exampleimport2.jl")
using .ExampleImport2
using .ExampleImport
tmp = TestStruct(2)
teststructmod!(tmp)
Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message ) (More Info)