function arguments and gensym



>
>
>f(s,t):=s[t];
>w:x;
>x[4]:5;
>f(w,4);
>
>it gives 5 but I, the user,  suppose the  definition f(s,t):=s[t] means for
> f(w,4) w[4] and not x[4]. 
> The global value of w as a symbol is incorrect here, we
>want to use the array w.
>

Is the function definition relevant here? Otherwise I would simplify the 
example to
w:x;
x[4]:5;
w[4];

which gives 5 as expected. The meaning of w[4] is I think:

(1) w has no array property and is not a list so evaluate it.
(2)  We now get x[4]. Since x has an array property we can evaluate x[4] 
to get 5.

This seems to be confirmed by the following experiments.

w:x;
x[4]:5;
w:1;
w[4];

This give an  error as evaluation of w yields 1[4].

w:x;
x[4]:5;
x:1;
w[4];

Now we get 5. w evaluates to x and since x has the array property,
x[4] evaluates to 5.

w:x;
x[4]:5;
x:[1,1,1,1,1,1,1,1];
w[4];

This is tricky! Now we still get 5. So maxima seems to prefer
the array property of x above its value which is a list.

w:x;
x:[1,1,1,1,1,1,1,1];
w[4];

Now x has no array property so its value is inspected. We get 1.

x[4]:5;
x:[1,1,1,1,1,1,1,1];
x[4];

We get  5. Maxima prefers again the array property.

Michel