Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
150 views
in Technique[技术] by (71.8m points)

Julia package developement: restarting the kernel wont compile the module

I am trying to learn how to develop packages in Julia. At the moment I have created a package Example.jlas follows

module Example  

greet() = print("Hello World!") # a simple function

include("functions.jl") # calls another file where I define functions f and g

export greet 
export f
export g

end

as well as the functions.jl file where I define two functions f and g:

f(x,y) = x^2+y^2
g(x,y) = x+y

Finally, I go to the runtests.jl file to test the package. All works ok except in the case I restart (for whatever reason) the kernel. Then, my runtests.jl will give me errors for

using Example
using Test

f(1,1)
g(2,2)

The error is that the functions are not defined! But it is fine if I use instead

using Example
using Test

Example.f(1,1)
Example.g(2,2)

In order f(1,1), g(2,2) to work like this I need to go to Example.jl and re-compile it. This is weird because I assumed that the export function in the module will export the functions and that everytime I call the module it compiles itslef. Obviously this is not the case.

So my question is how to make the module to compile everytime I call it by using Example?

question from:https://stackoverflow.com/questions/65645297/julia-package-developement-restarting-the-kernel-wont-compile-the-module

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...