I was wondering whether there is any way to protect a table. I have the following situation:
> f := table([ a = table([ a1 = 1, a2 = 2 ]), b = table([ b1 = 3, b2 = 4 ]) ]);
That is, f[a] returns another indexed table. Now, when I do protect(f), protect(f[a]) or even protect(f[a][a1]), I cannot change its value any more:
> f[a][a1] := test;
Error, attempting to assign to array/table `f` which is protected
But if I assign f[a] to a new variable g, then I can do it:
> g := f[a];
> g[a1] := test;
table([a = table([a1 = test, a2 = c]), d = table([d1 = i, d2 = j])])
I guess it has something to do with last_name_eval, but I'm not sure. The thing is that, if I can get this to work, I can use the elements from the table immediately, while I now have to work with an explicit copy of f[a] in order to avoid these possible changes to f[a] via g...
Thanks in advance for any reply.