> Imagine that you want to write a function which works like this:
> myfunc : splineinterpolate(xes,yes);
> myfunc(newx); /* gives the interpolated value based on the xes and yes
> that were passed to splineinterpolate*/
I agree that this would be a nice, clean way of doing things. I
really do. But Maxima was designed long before Scheme showed the Lisp
community the value of lexical scope, and it hasn't been redesigned
since.
So Maxima isn't really function-oriented, it is expression-oriented.
One can argue that this is a design flaw, but for now, it's what we
have. For example, one says diff(x^2,x) => 2*x rather than
diff(lambda([x],x^2),1) => lambda([x],2*x), and Maxima doesn't know
anything about "+" as an operator on functions, e.g. lambda([x],x) +
lambda([y],y) => lambda([q23],2*q23).
The more 'idiomatic' way of doing things in Maxima would be:
myexpr : splineinterpolate(xs, ys, 'var)$
subst(newx, var, myexpr);
or
myfunc(var) := ''( myexpr ) $
or
myfunc(var) := ''( splineinterpolate(xs,ys, 'var) )$
which is in fact the most common use of the ''(...) operator.
I do realize that function-as-value has a lot of good properties; it's
just that Maxima doesn't support functions-as-values very well.
-s