accessing functions in an array across different files

111 views
Skip to first unread message

Joseph Obiajulu

unread,
May 31, 2016, 2:50:51 AM5/31/16
to julia-dev
Say that I have some array of functions, `Fn[f1,f2,...,fn]`, in `file1.jl`. Now, I include `file1.jl` in a module `mod1` which is located in `file2.jl`. What is the best way to "export" all the functions in the `Fn[]` array, so that if I am `using mod1` in say some `file3.jl`, I could simply call f1().

Thanks for the help! 

Mike Innes

unread,
May 31, 2016, 5:34:30 AM5/31/16
to juli...@googlegroups.com
Working backwards, the way to do an export programmatically is to call something like:

eval(:(export $([:a, :b]...)))

The [:a, :b] must be an array of symbols. Assuming that you're doing some kind of code generation to create the functions it's probably better to collect those symbols directly or export them at the same time as creating them, but if that's not an option you can get the name of the function from methods(f) (I forget exactly which how, but you should be able to find it).
Message has been deleted

Joseph Obiajulu

unread,
May 31, 2016, 5:51:13 PM5/31/16
to julia-dev
Thanks for the help Mike. I'll give it a go, and let you know how it turns out. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages