CookBooks

Documentation for CookBooks.

CookBooks.CookBookType
cookbook = CookBook([sym1=fun1, sym2=fun2, ...])

Returns a cookbook, optionnally containing an initial set of recipes. Recipes are functions, identified by a symbol. Additional recipes can be added to the cookbook by:

push!(cookbook ; fun1, fun2 = fun1->(...))
cookbook.fun1 = fun1
cookbook.fun2 = fun1->(...)

Function argument names matter in order to identify dependencies between recipes. Here evaluating fun2 requires evaluating fun1 first, and passing the result of fun1 to fun2. Once the cookbook is complete, one opens at any time a fresh cooking session by:

session = open(cookbook; data1=val1, data2=val2, ...)

In addition to data provided as above at session creation time, data can be added to an existing session by:

session.sym = val

Data is fetched by:

val = session.sym

Recipes from the coobook will be called if the required data is not already present in the session. The session stores user-provided data and any additional data computed during its lifetime. A given result is computed at most once per session.

The special argument name all represents the session itself. Therefore a function :

function fun(all)
    (; data1, data2) = all
    ... # compute
    return something
end

is given the whole session as sole input argument. fun can then fetch arbitrary results from the session. This possibility is useful mostly if the inputs of the recipe are not always the same.

If a function has several methods with different argument names, it is called with the session as its sole argument. Checking methods and argument names is done each time fun is called.

source