Strange behavior with sum



I have the following function
f(torder, pvar):= block([
            lamda:make_array('any,torder+1),
            z:make_array('any,torder+1),
            lamdaSum:sum('lamda[i]*pvar^i,i,0,torder),
            zSum1:sum('z[i]*pvar^i,i,0,torder)*lamdaSum,
            zSum:sum('z[i]*pvar^i,i,0,torder)],
            zSum:lamdaSum*zSum,
            print(zSum,zSum1)
);
f(2,e) returns

(lamda  e  + lamda  e + lamda ) (z  e  + z  e + z )
      2           1          0    2       1      0

           2
      (z  e  + z  e + z ) lamdaSum
        2       1      0

so in the binding in the variable block, lamdaSum is not expanded, and
outside the block it is.
Since I need the expanded form, I need to know which behavior is
correct, and if the unexpanded
one is, then how can I convert to the expanded form, in case the
behavior changes in the future.

Dan Stanger
dan.stanger@ieee.org