Functions may leak information about names(!) of local variables.



van Nek wrote:
> (%i1) g(s):=block([t],local(t), t[4]:subvar(s,4), t[4])$
> (%i2) t[n]:=n^3$
> (%i3) g(t);
> (%o3) 				      t
> 				       4
> (%i4) g(s):=block([t],t[4]:subvar(s,4), t[4])$
> (%i5) g(t);
> (%o5) 				      64
>
> Hi Michel,
>
> the use of 'local' makes the difference here. As far as I understand (see doc of 'local'), 
> local(t) causes that all global information about t is forgotten and the substituted expression 
> subvar(t,4) is evaluated just as t[4], nothing more. 
>
> Volker van Nek
>   
This does not work: try

g(s):=block([t],t[4]:subvar(s,4), t[4]);
t[n]:=n^3;
u[n]:=n^4;
g(u);
256
g(t);
256

local is necessary to avoid the values of t being overwritten.

Cheers!
Michel