I would like to be able to define the values of a particular function for new inputs.
f[x1]=f1;
f[x2]=f2;
I would also like to be able redefine the values for most inputs.
f[x1]=f3;
f[x2]=f0;
But there are certain definitions I would like to protect.
f[x0]=f0;
Protect[f] protects all definitions and prevents me from defining the values for new inputs.
I could set/remove/set the Protected attribute for f but that isn't any fun because there are very few definitions I would like protected, and many that get defined and redefined.
My other thought would be to modify Set:
Unprotect[Set]
f::fixeddef="The definition of f for this value cannot be modified"
Set[f[x0],_]:=(Message[f::fixeddef]; $Failed)
SetAttributes[Set,Protected]
This doesn't completely work though:
f[x0]=f1 (* fails appropriately *)
{f[x0],f[x1]}={f3,f4} (* returns {f3,f4} instead of {f0,f4} *)
I assumed Set threads itself over nested lists, recursively calling Set until the lhs is a Symbol, but apprently I assumed wrong.
How does Set work and how can I protect the function definitions only for particular inputs?