I have certain parts of my code that show up in a lot of functions. They are simple blocks of math like:
a=x+2 b=a+3 ...
b are later used in different ways. One way of doing this is like this:
function fun(x) a=x+2 b=a+3 return a,b # later in the code a,b=fun(x)
but this gets cumbersome fast, as I have a lot of variables that are used and defined, plus a lot of them are StaticArrays and the whole thing gets a bit messy.
Is there some command to tell the compiler to insert a block of code into a function and that everything that gets declared/modified in that block is later seen by the function? Not with global variables, as most of these chunks create local variables that are used within parallelized for loops.
Performance is important.