Precompilation will spawn a new Julia process, so anything you define in the Main module can not be accessed when precompiling. Even neglecting precompilation, depending on the state of the user’s Main module like this seems like an unusual API choice though. For instance, an approach like this will be inherently type unstable. Why not let the user pass a type explicitly and parametrize on that?
function getWindSpeedT(::Velocity_Constant, WindVel, iT, _)
I have many of these functions, they have the same name, but a different type as first parameter. Not my design choice, a consequence of translating Matlab code that was switching the search path for the functions at runtime.
I still don’t understand why you need to create separate types if all that changes are the values in a yaml file. If you want your package to work with precompilation you will have to change your approach, as I said, as-is your design is not compatible with precompilation. I didn’t realize the types were actually defined in your package and not by the user. In that case your approach will work, but the issues around type-stability still stand
Yeah I agree with the change to the parent module of the fixed set of types. Using Main seems to weirdly restrict things to REPL work, which goes out the window if the user likes to change contextual modules often or happens to assign different things to the same names.
Not that it’d further help this resolved problem, but the PrecompileTools documentation says:
There are cases where you might want to precompile code but cannot safely execute that code: for example, you may need to connect to a database, or perhaps this is a plotting package but you may be currently on a headless server lacking a display, etc. In that case, your best option is to fall back on Julia’s own precompile function.
though it also explains that you’d need to do more work to discover and write more precompile calls for any useful runtime-dispatched callees.