Is there some type that I can pass into functions that would indicate that I don’t care about the result?
The background is that I always try to write in place functions. When I have a, b, c = f(x, y, z) I always implement it in terms of f!(a, b, c, x, y, z). Note that all variables are arrays. Currently, if I don’t need b and c, I still have to allocate memory for them and the function has to fill them.
Is there some type that I could pass to the function indicating that I don’t need the variables? Something like f!(a, nothing, nothing, x, y, z). The compiler could then produce a function that does not even do the computation for b and c, with code reduction and speedup as a result.
Note that this will cause code that reads from this array to break completely. Is probably obvious, but worth stating that you should only do this if you know how the function works.
While this is fun to brainstorm about, I believe that it will be very unlikely that everything folds down into nothing when using such an array in more complicated contexts. So just accepting a Union{AbstractArray, Nothing} and branching is most likely the way to go in practice.