On 2/22/06, van.Nek at gmx.net <van.Nek at gmx.net> wrote:
> (%i1) foo(a):= bar(a)$
> (%i2) bar(x):= a$
> (%i3) foo(1);
> (%o3) 1
> (%i4) bar(1);
> (%o4) a
> (%i5) a:2$
> (%i6) foo(1);
> (%o6) 1
> (%i7) bar(1);
> (%o7) 2
>
> This should not be intended. A bug?
What exactly do you find surprising? The variable "a" in function
"bar" is free. Maxima has dynamic scope, so foo(1) is equivalent to
block([a:1], bar(a) )
which is equivalent to
block([a:1], block([x:a], a ))
so foo(1) => 1.
On the other hand, bar(1) by itself is equivalent to
block([x:1], a )
so bar(1) => a.
Similarly for %i6 and %i7.
-s