I often need to debug by preventing some definition from evaluating and checking intermediate results. I accomplish this by doing initAll;clearAll[f,g,h]. I don’t like it because
- It forces you to put everything in a single init block
- It’s not flexible enough to only keep certain patterns like
f[1]unevaluated
Instead I’d like to have a list forbidden patterns and have any pattern that matches left unevaluated. How can I achieve this?
Edit
So far I found this pattern the most useful (it’s Michael Pilat’s answer except with HoldForm and BlankNullSequence)
eh[expr_, symbols : {___Symbol}] := Block[symbols, HoldForm@Evaluate[expr]]
Blockcan help with what you want:Do you want to prevent evaluation for certain down-value patterns of
f? (E.g., blockf[x_]but allowf[x_, y_])?UPDATE
Here’s a functional form: