Not an answer to give what you ask, but an alternative way to "fight" an old definition:
I put my definition(s) for a function func[]
in a single cell that begins with ClearAll
. If I have resources I want precomputed, I put those in a separate cell and define a way to access them from func[]
. Then I don't have to recompute them every time I adjust the API or code for func[]
.
func // ClearAll;
func // Options = {Method -> Automatic,...}; (* optional: default options *)
func // Attributes = {HoldFirst}; (* optional: attributes *)
func::usage = (* optional: messages *)
"func[x, n] computes something for nonnegative integers n.";
(* Definitions: *)
func[x_, 0] := 1;
func[x_, 1] := x;
func[x_, n_Integer?Positive] : 2 x func[x, n - 1] - func[x, n - 2];
There is no need for HoldFirst
in this function; the example just illustrates how to include options, attributes, etc. You don't have to use the //
style either. It's my preference to see func
start many lines in a row.