I wrote some code where my output function is defined in terms of various functions, themselves defined in terms of various functions, schematically like $f(x) = g(h(x))$, $h(x) = k(m(x))$, etc., as you do.
For a given x, the evaluation of each of these functions might take a while, and I would like to keep an eye on the stage my computation is at, e.g. (temporarily) printing "evaluating h", when $h(k)$ starts being computed, similarly to how Monitor[] does this for e.g. the iterator in a table.
I am looking for tips on how to do this nicely.
Currently I am defining e.g.
h[x_] := h[x_] = { PrintTemporary["evaluating h"] , (actual expression for the function) }[[2]]
which does the job. The construction with the list seems rather roundabout, but I am not sure how else to make sure the print happens every time the function is called (with a distinct argument). Is there a better, optimal, or even built-in option for this?
List
brackets, use parentheses to enclose the compound expression:h[x_] := h[x] = (PrintTemporary[StringForm["Evaluating h[``]", x]]; calculation );
$\endgroup$