Understanding passing functions with parameters as a parameter

Hey,

I’m having trouble understanding why my function below needs the HoldAll attribute.
My goal was to write a function that outputs the trace steps with frames around them.

Also… is there a more elegant way to achieve this?

Clear[traceFramed];
SetAttributes[traceFramed, HoldAll];
traceFramed[f_[n_Integer], filter_ : _] := 
  Column[Framed[#, FrameMargins -> Large] & /@ Trace[f[n], filter]];

Example: traceFramed[Range[5]]

Thank you very much!

Hi Timo,

without HoldAll or HoldFirst the argument gets evaluated and your function effectively sees traceFramed[{1, 2, 3, 4, 5}] - and for this (i.e. for the respective pattern) there is no definition made. It might be interesting for you to read e.g. The Standard Evaluation Procedure from the documentation.

Regards – Henrik

Thank you!
I will read the proposed guide!