Hi, congratulations for a great talk.
One thing that I missed in your talks (and most other presentations about Pluto) is the user case in which your Pluto code (let me call it application code) depends on many functions (let me call them based code) within your own package. This is often the case in my field (particle physics). Within a given package we may end up with dozens (or hundredths) of base code functions while the application code on itself is small.
One solution is to pack all the case code at the end of notebook, but I find this not very satisfactory. Another, is to include base code with “include” statements. Yet, another one is to “load” the base functions, using a function like this (should sound familiar to you):
function ingredients(path::String)
# this is from the Julia source code (evalfile in base/loading.jl)
# but with the modification that it returns the module instead of the last object
name = Symbol(basename(path))
m = Module(name)
Core.eval(m,
Expr(:toplevel,
:(eval(x) = $(Expr(:core, :eval))(name, x)),
:(include(x) = (Expr(:top, :include))(name, x)),
:(include(mapexpr::Function, x) = (Expr(:top, :include))(mapexpr, $name, x)),
:(include($path))))
m
end
This is the solution I use. Then in my notebook (for example):
lfi = ingredients(“…/src/LaserLab.jl”)
h1dtns0 = lfi.LaserLab.h1d(PhotonDF.dtime *ttrns, fdat.nbins, 50.0, fdat.dtmax)
Where h1d is an auxiliary function (a wrapper for histograms) defined in my base code.
Apologies for the lengthy explanation. My points:
-
The notion of “one notebook to program it all” is nice when it applies to demo code, in particular for teaching (I use it for that purpose all the time).
-
In realistic applications, the base code becomes large (and is still not packed in a tidy library), while the application code is often small (load dataframes, select, filter, plot). Then you need a number of “ugly” (actually not very ugly) fixed to have a practical solution.
-
However, I don’t see that case discussed in talks, and I have the feeling that the “fixes” could be improved. I think the developers of Pluto are overlooking a rather important user case.
Thanks for your attention!