Thank you for the above response, I will try and give you a more clear idea of what my intention has been.
Here is the simple file that I have decided to create as a manager for my files so that each module using another module actually refer to the exact same Type. Each of the folders in moduleContainingFolderList contains Julia modules. This module is run before anyothers to correctly add to LOAD_PATH.
#This module will modify LOAD_PATH to include all module directories
root_path = @__DIR__
push!(LOAD_PATH, root_path)
moduleContainingFolderList = [
"/gamemanagement",
"/heuristics",
"/representation",
"/util"
]
for i = 1:length(moduleContainingFolderList)
path = root_path * moduleContainingFolderList[i]
if !(path in LOAD_PATH)
push!(LOAD_PATH, path)
end
end
I am then able to use using moduleName
freely, but the problem was that all of the functions and types loaded this way seem to be entering the Main module, so that when I attempt to run my code I get “cannot convert” errors. Before I run my code, the module getting access to by using
is getting pre-compiled. After some further testing here, it seems like it was not ‘recompiling’ my “CallTimer.jl” after it was modified, but this still does not explain to me why it was ever being loaded as part of Main? Originally I was going to call it Timer, but I got a name conflict with Base, so perhaps this caused the error? The only way I can seem to get changes to be reflected across modules once they have been compiled is to completely restart Julia in ATOM, and run my LOAD_PATH modifying file again.
As you will see, i tried adding include_dependency("./../util/CallTimer.jl")
to get it to check file versions, but no luck.
Below are my actual modules, the CallTimer is in the folder “Amazons/util”, but the GameManager is in “Amazons/gamemanagement”.
module CallTimer
export TargetTimer, Flag, startTimer, getNewFlagTimer
struct TargetTimer
timeToElapse::Float64
target
f #f is the function to call on target after elapsed time
end
#This method should be called with the @async macro to run in the back
function startTimer(timer::TargetTimer)
sleep(timer.timeToElapse)
timer.f(timer.target)
end
mutable struct Flag
isRaised::Bool
end
function raiseFlag(flag::Flag)
flag.isRaised = true
end
function getNewFlagTimer(time::Float64)::Tuple{TargetTimer, Flag}
flag = Flag(false)
timer = TargetTimer(time, flag, raiseFlag)
println(typeof((timer, flag)))
return (timer, flag)
end
end
module GameManager
include_dependency("./../util/CallTimer.jl")
using Board
using CallTimer
mutable struct Game
masterBoard::BoardState
currentPlayerTurn::Piece
maxTimePerMove::Int
end
function slowCount(flagObj::Flag)
i = 0
while !(flagObj.flag) && i < 100
sleep(1)
i+=1
println(i)
end
end
(timer, flag) = getNewFlagTimer(5.0)
@async startTimer(timer)
slowCount(flag)
end
I know this is quite a horrendously long post, so thank you very much for your time.
Edit: Fixed a variable name, was relatively unimportant.