Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking .jl script in another .jl script. #4086

Closed
ghost opened this issue Aug 16, 2013 · 12 comments
Closed

Linking .jl script in another .jl script. #4086

ghost opened this issue Aug 16, 2013 · 12 comments

Comments

@ghost
Copy link

ghost commented Aug 16, 2013

Well, its just been a couple of days, I started using Julia. It might be a silly question, but unable to solve on my own.

File name : mee.jl

function mem(k)
k*10
end

File name : a.jl

function man(val)
require("mee.jl")
reload("mee.jl")
k = mem(val)
print(k)
end

executing require("a.jl") and then man(20) yeilds 200 as desired. But suppose, I change mee.jl function(2nd Line) as k*40 and save it.
Now, executing reload("a.jl") and then man(20) should yeild 800, but it doesn't, it still yeilds 200???
Is it a mistake which I am making in the execution process/Coding?

@staticfloat
Copy link
Member

What version of Julia are you using? With the current 0.2 builds this works as expected.

@quinnj
Copy link
Member

quinnj commented Aug 16, 2013

Dup of #265?

@staticfloat
Copy link
Member

Shouldn't be, I tried this on my computer and it works just fine.

@JeffBezanson
Copy link
Member

In a situation like this require should be done at the top level, not inside the function.

@ghost
Copy link
Author

ghost commented Aug 17, 2013

@JeffBezanson ...Well sir, its working now, by declaring 'require' and 'reload' function before the function delaration, problem has been solved.
Why is it so, can you please explain?

@JeffBezanson
Copy link
Member

Changes to top-level definitions only take effect for code starting from the top-level, not for currently-executing code inside a function.

@ghost
Copy link
Author

ghost commented Aug 17, 2013

Thankx @JeffBezanson ...
Presently have been using MATLAB for the thermal hydraulic system modelling, but due to its towering matrix size around 50000x20, and even more after running the code, it's real sluggish. In my next project, I am considering a shift towards Julia......

@ViralBShah
Copy link
Member

If you can port the current codebase to Julia, it will be great to see how well it performs with Julia.

@ghost
Copy link
Author

ghost commented Aug 17, 2013

Actually, the program composes a fusion of Simulink and couple of .m files.
If .m files can be interfaced with Julia, then for the simulink part, I can think of hardcoding the same.

@ViralBShah
Copy link
Member

Not sure how that would work, as I have no experience with simulink.

@ghost
Copy link
Author

ghost commented Aug 17, 2013

ok..but any idea of linking .m file to julia....

@pao
Copy link
Member

pao commented Aug 19, 2013

I'm not quite sure if it's what you're asking for, but check out @lindahua's https://github.com/lindahua/MATLAB.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants