Matlab-like code-loading?

Users of my package need to write small functions and small scripts that invoke those functions. The users are familiar with Matlab, and I would like to mimic Matlab’s code-loading protocol to ease the users’ learning curve in adopting Julia. So I am wondering if there exists a macro or package to make the following work. If the user invokes one of their functions inside their script, say myfunction, like this:

     x = myfunction(t)

then Julia will look for a file called myfunction.jl in a prespecified list of directories. Upon finding the file, Julia will load it. Thus, the user is expected to define function myfunction(...) inside the file myfunction.jl. Editing the file should cause the latest version of the code to get loaded the next time it is invoked. Ideally, the users should not need to know about Julia modules.

I understand that the Julia code-loading mechanism is more powerful and general than a simple search-path, but nonetheless, this simplified code-loading protocol may help get users on-board.

if you put myfunction() into a module and use Revise.jl, it should work? Otherwise, you can use Revise.includet() (notice the t)

1 Like