Cleaner way of passing many arguments between functions

This seems weird and non-idiomatic to me — you’re basically using tail calls to write a loop in an imperative language (which may overflow the stack since Julia doesn’t do tail-call optimization). Why not simply write a second loop, for example:

function mainAlgo(someRef, otherStruct, argStruct)
     a, b, c, d = argStruct # unpack the variables for convenience and mutation
     while outerloop_condition
          while someRef[]
               #do function for some of the arguments
          end
          # update the arguments for the next outer iteration
      end
end

(The someRef[] check confuses me, too. Are you thinking of running this loop asynchronously and having some other thread/task update someRef[] to control when mainAlgo terminates? That’s a pretty confusing control-flow structure. If not, why use a Ref argument?)